{"record":{"id":"d27aeba0b685a541","repo":"laurent22/joplin","slug":"cannot-find-s-d27aeb","errorCode":null,"errorMessage":"Cannot find \"%s\".","messagePattern":"Cannot find \"(.+?)\"\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/app-cli/app/command-search.ts","lineNumber":28,"sourceCode":"\t}\n\n\tpublic override description() {\n\t\treturn _('Searches for the given <pattern> in all the notes.');\n\t}\n\n\tpublic override compatibleUis() {\n\t\treturn ['gui'];\n\t}\n\n\t// eslint-disable-next-line id-denylist -- `notebook` is the CLI argument name declared in usage() and accessed via bracket notation; the identifier appears here only as a type property key\n\tpublic override async action(args: { pattern: string; notebook?: string }) {\n\t\tconst pattern = args['pattern'];\n\t\tconst folderTitle = args['notebook'];\n\n\t\tlet folder = null;\n\t\tif (folderTitle) {\n\t\t\tfolder = await Folder.loadByTitle(folderTitle);\n\t\t\tif (!folder) throw new Error(_('Cannot find \"%s\".', folderTitle));\n\t\t}\n\n\t\tconst searchId = uuid.create();\n\n\t\tthis.dispatch({\n\t\t\ttype: 'SEARCH_ADD',\n\t\t\tsearch: {\n\t\t\t\tid: searchId,\n\t\t\t\ttitle: pattern,\n\t\t\t\tquery_pattern: pattern,\n\t\t\t\tquery_folder_id: folder ? folder.id : '',\n\t\t\t\ttype_: BaseModel.TYPE_SEARCH,\n\t\t\t},\n\t\t});\n\n\t\tthis.dispatch({\n\t\t\ttype: 'SEARCH_SELECT',\n\t\t\tid: searchId,","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/laurent22/joplin/blob/2654b33620775080d1d59c552259d41e33dad3d2/packages/app-cli/app/command-search.ts#L10-L46","documentation":"Thrown by the `search` CLI command when the optional `--notebook` argument names a folder that Folder.loadByTitle cannot resolve in the local database. The command uses the title (not id) to look up the folder that should scope the saved search, so a non-existent or mistyped notebook title aborts before the SEARCH_ADD dispatch. The %s placeholder is replaced with the offending title for display.","triggerScenarios":"Running `:search <pattern> --notebook <title>` (or the equivalent GUI invocation routed through this command) where `<title>` does not match any Folder.title in the current profile's database. Also triggered if the folder exists only on a sync target that has not yet been pulled locally, or when the title contains whitespace/casing that differs from the stored value.","commonSituations":"Typos in the notebook name; referencing a notebook created on another device before the first sync completes; duplicate or renamed notebooks where the user recalls the old title; running the command against a fresh/empty profile.","solutions":["Run `ls notebook` / `:notebook list` to confirm the exact stored title and re-run with the correct spelling and case.","If the notebook lives on another device, run `:sync` first so the folder is replicated into the local database, then retry the search.","If the title contains spaces or special characters, quote it exactly as shown by the notebook list command.","Omit `--notebook` entirely to create an unscoped (global) saved search instead."],"exampleFix":"// before\nfolder = await Folder.loadByTitle(folderTitle);\nif (!folder) throw new Error(_('Cannot find \"%s\".', folderTitle));\n\n// after - hint the user with available titles before failing\nconst candidates = await Folder.all();\nconst folder = candidates.find(f => f.title === folderTitle);\nif (!folder) throw new Error(_('Cannot find \"%s\". Known notebooks: %s', folderTitle, candidates.map(f => f.title).join(', ')));","handlingStrategy":"validation","validationCode":"// Before calling the command, resolve the folder title yourself and show a helpful error.\nconst folder = await Folder.loadByTitle(notebookTitle);\nif (!folder) {\n\tthrow new Error(`Notebook \"${notebookTitle}\" not found. Run \\`ls notebook\\` first.`);\n}","typeGuard":"const isNonEmptyString = (v: unknown): v is string => typeof v === 'string' && v.trim().length > 0;","tryCatchPattern":"try {\n\tawait app().executeCommand(['search', pattern, '--notebook', notebookTitle]);\n} catch (e) {\n\tif (/Cannot find/.test(e.message)) { /* prompt user for correct notebook title */ }\n\telse throw e;\n}","preventionTips":["Always list notebooks before referencing one by title so you copy the exact stored value.","Sync before referencing a notebook that may only exist on another device.","Quote notebook titles containing spaces."],"tags":["notebook","folder","search","cli","not-found"],"backgroundTag":null,"analyzedSha":"2654b33620775080d1d59c552259d41e33dad3d2","analyzedAt":"2026-08-12T14:26:46.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}