{"record":{"id":"671b29abf0bb3777","repo":"tobi/qmd","slug":"collection-name-is-required-collections-must-be-d","errorCode":null,"errorMessage":"Collection name is required. Collections must be defined in ~/.config/qmd/index.yml","messagePattern":"Collection name is required\\. Collections must be defined in ~/\\.config/qmd/index\\.yml","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/qmd.ts","lineNumber":1917,"sourceCode":"  yamlRenameCollectionFn(oldName, newName);\n  closeDb();\n\n  console.log(`${c.green}✓${c.reset} Renamed collection '${oldName}' to '${newName}'`);\n  console.log(`  Virtual paths updated: ${c.cyan}qmd://${oldName}/${c.reset} → ${c.cyan}qmd://${newName}/${c.reset}`);\n}\n\nasync function indexFiles(pwd?: string, globPattern: string = DEFAULT_GLOB, collectionName?: string, suppressEmbedNotice: boolean = false, ignorePatterns?: string[]): Promise<void> {\n  const db = getDb();\n  const resolvedPwd = pwd || getPwd();\n  const now = new Date().toISOString();\n  const excludeDirs = [\"node_modules\", \".git\", \".cache\", \"vendor\", \"dist\", \"build\"];\n\n  // Clear Ollama cache on index\n  clearCache(db);\n\n  // Collection name must be provided (from YAML)\n  if (!collectionName) {\n    throw new Error(\"Collection name is required. Collections must be defined in ~/.config/qmd/index.yml\");\n  }\n\n  console.log(`Collection: ${resolvedPwd} (${globPattern})`);\n\n  progress.indeterminate();\n  const allIgnore = [\n    ...excludeDirs.map(d => `**/${d}/**`),\n    ...(ignorePatterns || []),\n  ];\n  const allFiles: string[] = await fastGlob(splitGlobMask(globPattern), {\n    cwd: resolvedPwd,\n    onlyFiles: true,\n    followSymbolicLinks: false,\n    dot: false,\n    ignore: allIgnore,\n  });\n  // Filter hidden files/folders (dot: false handles top-level but not nested)\n  const files = allFiles.filter(file => {","sourceCodeStart":1899,"sourceCodeEnd":1935,"githubUrl":"https://github.com/tobi/qmd/blob/dbfd0b4736aeaf761d1a16ca8e424f071df8feb9/src/cli/qmd.ts#L1899-L1935","documentation":"Thrown during the index command when no collection name could be resolved for the current directory. Collections must be declared in ~/.config/qmd/index.yml (or project .qmd/index.yml); the indexer will not guess a name.","triggerScenarios":"Running `qmd update`/index in a directory that is not under any configured collection root, or when the YAML config lacks a name for the matching path.","commonSituations":"Hand-edited index.yml missing the name field; running qmd from a subdirectory not covered by any collection path; config file at the wrong location.","solutions":["Check ~/.config/qmd/index.yml has an entry whose path covers the cwd and includes a name","Re-add the collection properly: `qmd collection add . --name <n>` from the project root","Verify with `qmd collection list` that the collection and name exist"],"exampleFix":"# before (~/.config/qmd/index.yml)\ncollections:\n  - path: ~/notes\n# after\ncollections:\n  - path: ~/notes\n    name: notes","handlingStrategy":"validation","validationCode":"const cfg = parse(readFileSync(join(homedir(), '.config/qmd/index.yml'), 'utf8'));\nconst cwd = process.cwd();\nconst hasCoveringNamedCollection = (cfg.collections ?? []).some(c => c.name && cwd.startsWith(resolve(c.path)));","typeGuard":"const collectionCovers = (c: {path: string; name?: string}, cwd: string) => Boolean(c.name) && (resolve(cwd) + '/').startsWith(resolve(c.path) + '/');","tryCatchPattern":null,"preventionTips":["Prefer `qmd collection add . --name <n>` over hand-editing index.yml","Run `qmd collection list` to confirm the name/path mapping before indexing"],"tags":["cli","config","collection"],"backgroundTag":"missing-config-value","analyzedSha":"dbfd0b4736aeaf761d1a16ca8e424f071df8feb9","analyzedAt":"2026-08-28T18:07:46.628Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}