{"record":{"id":"6b79aae080e920ce","repo":"laurent22/joplin","slug":"invalid-command-s","errorCode":null,"errorMessage":"Invalid command: \"%s\"","messagePattern":"Invalid command: \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/app-cli/app/command-tag.ts","lineNumber":94,"sourceCode":"\t\t\t} else {\n\t\t\t\tconst tags: TagEntity[] = await Tag.all();\n\t\t\t\ttags.map(tag => {\n\t\t\t\t\tthis.stdout(tag.title);\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (command === 'notetags') {\n\t\t\tif (args.tag) {\n\t\t\t\tconst note = await app().loadItem(ModelType.Note, args.tag);\n\t\t\t\tif (!note) throw new Error(_('Cannot find \"%s\".', args.tag));\n\t\t\t\tconst tags: TagEntity[] = await Tag.tagsByNoteId(note.id);\n\t\t\t\ttags.map(tag => {\n\t\t\t\t\tthis.stdout(tag.title);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tthrow new Error(_('Cannot find \"%s\".', ''));\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new Error(_('Invalid command: \"%s\"', command));\n\t\t}\n\t}\n}\n\nmodule.exports = Command;\n","sourceCodeStart":76,"sourceCodeEnd":100,"githubUrl":"https://github.com/laurent22/joplin/blob/2654b33620775080d1d59c552259d41e33dad3d2/packages/app-cli/app/command-tag.ts#L76-L100","documentation":"Terminal fallback throw at the end of the `tag` command's if/else chain: if `args['tag-command']` is not one of `add`, `remove`, `list`, or `notetags`, execution reaches the else and throws. The invalid command value is interpolated via `%s` so the user sees what they typed. This is an enum-validation failure on the subcommand.","triggerScenarios":"Running `:tag foo ...` or any unrecognized first token; casing mismatch (matching is exact lowercase); passing a subcommand from outdated documentation that no longer exists.","commonSituations":"Typo in the subcommand; using `tags`/`delete`/`rm` instead of the supported `add`/`remove`/`list`/`notetags`; empty `tag-command` from a malformed invocation.","solutions":["Use one of the supported subcommands: add, remove, list, notetags.","Run `:help tag` to see the current usage string.","When scripting, validate `tag-command` against the known set before invoking."],"exampleFix":"// before\nthrow new Error(_('Invalid command: \"%s\"', command));\n\n// after - list valid commands in the message\nthrow new Error(_('Invalid tag-command: \"%s\". Valid commands: add, remove, list, notetags.', command));","handlingStrategy":"validation","validationCode":"const VALID = ['add','remove','list','notetags'];\nif (!VALID.includes(command)) {\n\tthrow new Error(`Invalid tag-command \"${command}\". Valid: ${VALID.join(', ')}`);\n}","typeGuard":"const isTagCommand = (c: string): c is 'add'|'remove'|'list'|'notetags' =>\n\t['add','remove','list','notetags'].includes(c);","tryCatchPattern":"try {\n\tawait app().executeCommand(['tag', subcommand, tag, note].filter(Boolean));\n} catch (e) {\n\tif (/Invalid command/.test(e.message)) { /* show help, reprompt */ }\n\telse throw e;\n}","preventionTips":["Validate the subcommand against the known enum before invoking.","Subcommand matching is case-sensitive lowercase.","Surface the full valid set in your error message."],"tags":["tag","invalid-command","argument-validation","cli"],"backgroundTag":null,"analyzedSha":"2654b33620775080d1d59c552259d41e33dad3d2","analyzedAt":"2026-08-12T14:26:46.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}