{"record":{"id":"042fddaec5418507","repo":"nodejs/node","slug":"sqlitecachestore-options-must-be-an-object","errorCode":null,"errorMessage":"SqliteCacheStore options must be an object","messagePattern":"SqliteCacheStore options must be an object","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"deps/undici/src/lib/cache/sqlite-cache-store.js","lineNumber":81,"sourceCode":"  #deleteByUrlQuery\n\n  /**\n   * @type {import('node:sqlite').StatementSync}\n   */\n  #countEntriesQuery\n\n  /**\n   * @type {import('node:sqlite').StatementSync | null}\n   */\n  #deleteOldValuesQuery\n\n  /**\n   * @param {import('../../types/cache-interceptor.d.ts').default.SqliteCacheStoreOpts | undefined} opts\n   */\n  constructor (opts) {\n    if (opts) {\n      if (typeof opts !== 'object') {\n        throw new TypeError('SqliteCacheStore options must be an object')\n      }\n\n      if (opts.maxEntrySize !== undefined) {\n        if (\n          typeof opts.maxEntrySize !== 'number' ||\n          !Number.isInteger(opts.maxEntrySize) ||\n          opts.maxEntrySize < 0\n        ) {\n          throw new TypeError('SqliteCacheStore options.maxEntrySize must be a non-negative integer')\n        }\n\n        if (opts.maxEntrySize > MAX_ENTRY_SIZE) {\n          throw new TypeError('SqliteCacheStore options.maxEntrySize must be less than 2gb')\n        }\n\n        this.#maxEntrySize = opts.maxEntrySize\n      }\n","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/undici/src/lib/cache/sqlite-cache-store.js#L63-L99","documentation":"Thrown by the SqliteCacheStore constructor when opts is truthy but not an object (e.g. a string, number, array-without-intent, or a primitive wrapper). The constructor only branches into object validation when opts is truthy, then immediately asserts typeof === 'object'; passing a non-object primitive triggers this. Null is allowed (no opts) because the outer guard is `if (opts)`.","triggerScenarios":"new SqliteCacheStore('/var/cache.db'), new SqliteCacheStore(123), new SqliteCacheStore(true), or new SqliteCacheStore([':memory:']). Reproduces whenever a config loader passes a scalar where an options object is expected.","commonSituations":"Confusing the location string with the options object (users assume the store takes a path directly); wiring a YAML/env config that yields a scalar; copy-paste from MemoryCacheStore which takes no options.","solutions":["Pass an options object: new SqliteCacheStore({ location: '/var/cache.db', maxEntrySize, maxCount }).","If you only need an in-memory DB, call new SqliteCacheStore() or new SqliteCacheStore(undefined) with no argument.","If you have a bare path string, wrap it: new SqliteCacheStore({ location: path }).","Verify your config loader returns an object (not a stringified JSON you forgot to parse)."],"exampleFix":"// before\nconst store = new SqliteCacheStore('/var/cache/undici.db')\n// after\nconst store = new SqliteCacheStore({ location: '/var/cache/undici.db' })","handlingStrategy":"type-guard","validationCode":"function makeSqliteStore(raw) {\n  const opts = raw == null || typeof raw === 'object' ? raw : null\n  if (opts === null) throw new TypeError('SqliteCacheStore options must be an object')\n  return new SqliteCacheStore(opts)\n}","typeGuard":"function isSqliteOpts(v) {\n  return v == null || (typeof v === 'object' && !Array.isArray(v))\n}","tryCatchPattern":null,"preventionTips":["Pass an object literal { location, maxEntrySize, maxCount }.","If you only have a path string, wrap it as { location: path }.","Keep a typed factory function so the options shape is enforced.","Treat null/undefined as 'no options'; never pass a scalar."],"tags":["cache","sqlite","validation","constructor","undici"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}