{"record":{"id":"a67d9eef884f6237","repo":"tobi/qmd","slug":"dbpath-is-required","errorCode":null,"errorMessage":"dbPath is required","messagePattern":"dbPath is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/index.ts","lineNumber":354,"sourceCode":" * })\n *\n * // With inline config (no files needed besides the DB)\n * const store = await createStore({\n *   dbPath: './index.sqlite',\n *   config: {\n *     collections: {\n *       docs: { path: '/path/to/docs', pattern: '**\\/*.md' }\n *     }\n *   }\n * })\n *\n * const results = await store.search({ query: \"authentication flow\" })\n * await store.close()\n * ```\n */\nexport async function createStore(options: StoreOptions): Promise<QMDStore> {\n  if (!options.dbPath) {\n    throw new Error(\"dbPath is required\");\n  }\n  if (options.configPath && options.config) {\n    throw new Error(\"Provide either configPath or config, not both\");\n  }\n\n  // Create the internal store (opens DB, creates tables)\n  const internal = createStoreInternal(options.dbPath);\n  const db = internal.db;\n\n  // Track whether we have a YAML config path for write-through\n  const hasYamlConfig = !!options.configPath;\n\n  // Sync config into SQLite store_collections\n  let config: CollectionConfig | undefined;\n  if (options.configPath) {\n    // YAML mode: inject config source for write-through, sync to DB\n    setConfigSource({ configPath: options.configPath });\n    config = loadConfig();","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/tobi/qmd/blob/dbfd0b4736aeaf761d1a16ca8e424f071df8feb9/src/index.ts#L336-L372","documentation":"createStore validates its options and requires dbPath, the SQLite database location. Without it the store has nowhere to open/create the index, so it fails fast before touching the filesystem.","triggerScenarios":"Calling createStore({}) or createStore({configPath: './qmd.yaml'}) with no dbPath; passing a mistyped key like dbpath or path.","commonSituations":"Quick integrations copying example code but omitting dbPath; refactors renaming StoreOptions fields; passing options built from an env var that is undefined.","solutions":["Supply options.dbPath, e.g. createStore({dbPath: '~/.cache/qmd/index.sqlite', configPath: './qmd.yaml'})","Check for typos in the option name","Default dbPath from an env var: process.env.QMD_DB ?? fallback"],"exampleFix":"// before\nconst store = await createStore({ configPath: './qmd.yaml' });\n// after\nconst store = await createStore({\n  dbPath: './qmd-index.sqlite',\n  configPath: './qmd.yaml',\n});\n","handlingStrategy":"validation","validationCode":"function assertStoreOptions(o: StoreOptions): asserts o is StoreOptions & { dbPath: string } {\n  if (!o.dbPath) throw new Error('dbPath is required');\n}","typeGuard":"const hasDbPath = (o: StoreOptions): o is StoreOptions & { dbPath: string } =>\n  typeof o.dbPath === 'string' && o.dbPath.length > 0;","tryCatchPattern":null,"preventionTips":["Type StoreOptions explicitly so TS flags missing dbPath","Default dbPath from env: process.env.QMD_DB ?? './qmd.sqlite'","Write a tiny factory wrapper that centralizes option validation"],"tags":["api-misuse","validation","store-options"],"backgroundTag":"missing-required-parameter","analyzedSha":"dbfd0b4736aeaf761d1a16ca8e424f071df8feb9","analyzedAt":"2026-08-28T18:07:46.628Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}