{"record":{"id":"fbca170a0c255798","repo":"diegosouzapw/OmniRoute","slug":"cache-size-must-be-a-positive-kib-value-between-1","errorCode":null,"errorMessage":"cache_size must be a positive KiB value between 1 and 1000000","messagePattern":"cache_size must be a positive KiB value between 1 and 1000000","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/db/optimizationSettings.ts","lineNumber":64,"sourceCode":"}\n\nfunction normalizeVacuumHour(value: unknown, fallback: number): number {\n  const numeric = Number(value);\n  if (!Number.isFinite(numeric)) return fallback;\n  return Math.min(23, Math.max(0, Math.floor(numeric)));\n}\n\nfunction normalizeStoredCacheSizeKb(value: unknown, fallback: number): number {\n  const numeric = Number(value);\n  if (!Number.isFinite(numeric)) return fallback;\n  const cacheSizeKb = Math.floor(numeric);\n  if (cacheSizeKb < 1 || cacheSizeKb > 1000000) return fallback;\n  return cacheSizeKb;\n}\n\nfunction requireCacheSizeKb(value: number): number {\n  if (!Number.isInteger(value) || value < 1 || value > 1000000) {\n    throw new Error(\"cache_size must be a positive KiB value between 1 and 1000000\");\n  }\n  return value;\n}\n\nfunction mergeOptimizationSettings(\n  target: DatabaseOptimizationSettings,\n  value: unknown\n): DatabaseOptimizationSettings {\n  if (!isRecord(value)) return target;\n  return {\n    ...target,\n    autoVacuumMode: normalizeAutoVacuumMode(value.autoVacuumMode, target.autoVacuumMode),\n    scheduledVacuum:\n      typeof value.scheduledVacuum === \"string\" &&\n      [\"never\", \"daily\", \"weekly\", \"monthly\"].includes(value.scheduledVacuum)\n        ? (value.scheduledVacuum as DatabaseOptimizationSettings[\"scheduledVacuum\"])\n        : target.scheduledVacuum,\n    vacuumHour: normalizeVacuumHour(value.vacuumHour, target.vacuumHour),","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/db/optimizationSettings.ts#L46-L82","documentation":"Guard in requireCacheSizeKb: the requested SQLite cache_size (in KiB) is not a positive integer within 1..1000000, so the pragma would be invalid or unsafe; the caller is stopped before applying it instead of silently clamping to a fallback.","triggerScenarios":"Thrown at src/lib/db/optimizationSettings.ts:64 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide an integer cache_size between 1 and 1000000 KiB","Normalize user input (round/floor) and enforce the range in the settings UI before persisting","Fall back to the default cache size if the requested value is unusable"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}