{"record":{"id":"24aceb683079bd6d","repo":"neoclide/coc.nvim","slug":"command-command-not-found","errorCode":null,"errorMessage":"Command: ${command} not found","messagePattern":"Command: (.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/commands.ts","lineNumber":159,"sourceCode":"    })\n  }\n\n  /**\n   * Executes the command denoted by the given command identifier.\n   *\n   * * *Note 1:* When executing an editor command not all types are allowed to\n   * be passed as arguments. Allowed are the primitive types `string`, `boolean`,\n   * `number`, `undefined`, and `null`, as well as [`Position`](#Position), [`Range`](#Range), [`URI`](#URI) and [`Location`](#Location).\n   * * *Note 2:* There are no restrictions when executing commands that have been contributed\n   * by extensions.\n   * @param command Identifier of the command to execute.\n   * @param rest Parameters passed to the command function.\n   * @return A promise that resolves to the returned value of the given command. `undefined` when\n   * the command handler function doesn't return anything.\n   */\n  public executeCommand<T>(command: string, ...rest: any[]): Promise<T> {\n    let cmd = this.commands.get(command)\n    if (!cmd) throw new Error(`Command: ${command} not found`)\n    return Promise.resolve(cmd.execute.apply(cmd, rest))\n  }\n\n  /**\n   * @internal\n   * Used for user invoked command.\n   */\n  public async fireCommand(id: string, ...args: any[]): Promise<unknown> {\n    // needed to load onCommand extensions\n    await events.fire('Command', [id])\n    let start = Date.now()\n    let res = await this.executeCommand(id, ...args)\n    if (args.length == 0) {\n      await this.addRecent(id, events.lastChangeTs > start)\n    }\n    return res\n  }\n  /**","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/neoclide/coc.nvim/blob/50e974d9692461a69147d5cab146a8d3e439abe4/src/commands.ts#L141-L177","documentation":"coc.nvim's command registry has no entry under the requested name, so commands.executeCommand throws. This is thrown synchronously when the command string does not match any registered command (registered via registerCommand, built-in commands, or extension contributions).","triggerScenarios":"Calling coc.actions.executeCommand('some.command') with a typo, executing a command contributed by an extension that is not installed or failed to activate, or executing a command before its extension registered it.","commonSituations":"User keymaps or statusline configs hardcode a coc command name from outdated docs; extensions renamed/removed commands; commands invoked in init scripts before extensions load.","solutions":["Check the exact command name against the extension's README or :CocList commands output","Ensure the extension providing the command is installed and activated","Wrap executeCommand in try/catch or check the registry before invoking","If lazy-loading, wait for extension activation before calling the command"],"exampleFix":"// before\nawait actions.executeCommand('coc clangd.switchSourceHeader')\n// after\nconst name = 'clangd.switchSourceHeader'\nif (commands.has(name)) await actions.executeCommand(name)\nelse log(`command ${name} not available`)","handlingStrategy":"try-catch","validationCode":"// check registry before executing\nif (!commands.has('my.command')) return notify('command not available')","typeGuard":null,"tryCatchPattern":"try {\n  await actions.executeCommand(name, ...args)\n} catch (e) {\n  if (String(e.message).includes('not found')) notify(`Unknown command: ${name}`)\n  else throw e\n}","preventionTips":["List available commands with :CocList commands before wiring keymaps","Copy command names from the extension's official docs","Guard user-configured command names with a registry check","Ensure extensions are activated before invoking their commands"],"tags":["command","registry","api-misuse"],"backgroundTag":"command-not-found","analyzedSha":"50e974d9692461a69147d5cab146a8d3e439abe4","analyzedAt":"2026-08-31T11:17:23.966Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}