{"record":{"id":"40def4323f7dbbcd","repo":"laurent22/joplin","slug":"more-than-one-item-match-s-please-narrow-down","errorCode":null,"errorMessage":"More than one item match \"%s\". Please narrow down your query.","messagePattern":"More than one item match \"(.+?)\"\\. Please narrow down your query\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/app-cli/app/app.ts","lineNumber":67,"sourceCode":"\t\t\ttype = ModelType.Folder;\n\t\t\tpattern = pattern.substr(1);\n\t\t}\n\t\treturn this.loadItem(type, pattern, options);\n\t}\n\n\tpublic async loadItem(type: FolderOrNoteType, pattern: string, options: { parent?: FolderEntity } | null = null) {\n\t\tconst output = await this.loadItems(type, pattern, options);\n\n\t\tif (output.length > 1) {\n\t\t\t// output.sort((a, b) => { return a.user_updated_time < b.user_updated_time ? +1 : -1; });\n\n\t\t\t// let answers = { 0: _('[Cancel]') };\n\t\t\t// for (let i = 0; i < output.length; i++) {\n\t\t\t// \tanswers[i + 1] = output[i].title;\n\t\t\t// }\n\n\t\t\t// Not really useful with new UI?\n\t\t\tthrow new Error(_('More than one item match \"%s\". Please narrow down your query.', pattern));\n\n\t\t\t// let msg = _('More than one item match \"%s\". Please select one:', pattern);\n\t\t\t// const response = await cliUtils.promptMcq(msg, answers);\n\t\t\t// if (!response) return null;\n\n\t\t\t// return output[response - 1];\n\t\t} else {\n\t\t\treturn output.length ? output[0] : null;\n\t\t}\n\t}\n\n\tpublic async loadItemOrFail(type: FolderOrNoteType, pattern: string) {\n\t\tconst output = await this.loadItem(type, pattern);\n\t\tif (!output) throw new Error(_('Cannot find \"%s\".', pattern));\n\t\treturn output;\n\t}\n\n\tpublic async loadItems(type: FolderOrNoteType, pattern: string, options: { parent?: FolderEntity } | null = null): Promise<(FolderEntity | NoteEntity)[]> {","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/laurent22/joplin/blob/2654b33620775080d1d59c552259d41e33dad3d2/packages/app-cli/app/app.ts#L49-L85","documentation":"App.loadItem wraps loadItems and, when more than one item matches the pattern, throws 'More than one item match' because the interactive multiple-choice disambiguation UI was commented out. The caller must supply a more specific pattern. The message is i18n-translated via _().","triggerScenarios":"Two or more notes (or notebooks) share a matching title, or a short partial id prefix matches multiple rows; e.g. running 'cat test' when several notes are titled 'test', or a 2-character id prefix that is non-unique.","commonSituations":"Duplicate note titles in the same notebook; short partial ids; wildcard-like patterns that expand to many matches; bulk-imported data with repeated names.","solutions":["Use the full, unique title or the complete item id.","Select the specific notebook first with 'use <notebook>' to scope title lookups.","Rename one of the duplicates so the title is unique.","Use a longer partial id (loadByPartialId requires length >= 2 but longer prefixes are more unique)."],"exampleFix":"// before\n//   const item = await app().loadItem(ModelType.Note, 'test'); // throws if >1 match\n// after\n//   const items = await app().loadItems(ModelType.Note, 'test');\n//   if (items.length > 1) {\n//     // disambiguate: list matches and pick by full id\n//     const chosen = items[0]; // user selects\n//   }","handlingStrategy":"validation","validationCode":"const items = await app().loadItems(type, pattern, options);\nif (items.length > 1) {\n  // surface the matches so the user can pick a unique title/id\n  throw new Error(`Multiple matches: ${items.map(i => i.title).join(', ')}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const item = await app().loadItem(type, pattern);\n} catch (e) {\n  if (/More than one item match/.test(e.message)) {\n    // list candidates and re-prompt with a more specific pattern\n  }\n}","preventionTips":["Prefer full item ids over titles in scripts.","Scope lookups to a specific notebook before matching by title.","Keep note titles unique within a notebook."],"tags":["cli","item-lookup","ambiguity","i18n"],"backgroundTag":null,"analyzedSha":"2654b33620775080d1d59c552259d41e33dad3d2","analyzedAt":"2026-08-12T14:26:46.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}