neoclide/coc.nvim · error
default action "${defaultAction}" not found
Error message
default action "${defaultAction}" not found What it means
The list session resolves which action to run when the user presses Enter. It looks up an action by the `defaultAction` name declared on the list definition, falling back to the first registered action. This error is thrown only when the list defines no actions at all, so there is nothing to fall back to.
Source
Thrown at src/list/session.ts:285
* Window id used by list.
* @returns {number | undefined}
*/
public get winid(): number | undefined {
return this.ui.winid
}
public get length(): number {
return this.ui.length
}
public get defaultAction(): ListAction {
let { defaultAction, actions, name } = this.list
let config = workspace.getConfiguration(`list.source.${name}`)
let action: ListAction
if (config.defaultAction) action = actions.find(o => o.name == config.defaultAction)
if (!action) action = actions.find(o => o.name == defaultAction)
if (!action) action = actions[0]
if (!action) throw new Error(`default action "${defaultAction}" not found`)
return action
}
public async hide(notify = false, isVim = workspace.isVim): Promise<void> {
if (this.hidden) return
let { nvim, timer, targetWinid, context } = this
let { winid } = this.ui
if (timer) clearTimeout(timer)
this.worker.stop()
this.history.add()
this.ui.reset()
db.save()
this.hidden = true
nvim.pauseNotification()
if (!isVim) nvim.call('coc#prompt#stop_prompt', ['list'], true)
if (winid) nvim.call('coc#list#close', [winid, context.options.position, targetWinid, this.savedHeight], true)
if (notify) {
nvim.resumeNotification(true, true)View on GitHub (pinned to 50e974d969)
Solutions
- Ensure the list definition registers at least one action in its `actions` array
- Verify the `defaultAction` name on the list matches one of the registered action names exactly
- Check the user config `list.source.<name>.defaultAction` for typos if it is set
- Update or reinstall the extension providing the broken list
Example fix
// before
let list = { name: 'mylist', defaultAction: 'open', actions: [] }
// after
let list = { name: 'mylist', defaultAction: 'open', actions: [{ name: 'open', execute: async () => {} }] } Defensive patterns
Strategy: validation
Validate before calling
const cfg = workspace.getConfiguration(`list.source.${name}`)
const wanted = cfg.defaultAction ?? list.defaultAction
const ok = list.actions?.some(a => a.name === wanted)
if (!ok) throw new Error(`List '${name}' has no action '${wanted}' — check list definition`)
await listManager.create(name) Type guard
function hasAction(list: ListInfo, name?: string): boolean {
return Array.isArray(list.actions) && list.actions.length > 0 &&
(!name || list.actions.some(a => a.name === name))
} Try / catch
try {
await session.doAction()
} catch (e) {
if (String(e.message).includes('default action')) {
window.showMessage(`List '${listName}' has no valid default action`, 'error')
} else throw e
} Prevention
- Always register at least one action in every custom list
- Keep defaultAction name in sync with action names when refactoring
- Validate user-provided list.source.<name>.defaultAction values against the list's actions
- Test each list with :CocList <name> after registration
When it happens
Trigger: Calling a list API (or triggering the default action of a list) whose List definition has an empty `actions` array and whose `defaultAction` name matches no registered action, so `actions.find(...)` twice returns undefined and `actions[0]` is undefined.
Common situations: A custom list was registered with no actions or a typo in the action name; a user setting `list.source.<name>.defaultAction` points to a non-existent action but the list itself also has zero actions; a list definition was partially migrated/renamed.
Related errors
- Invalid action ${action}
- Action ${key} doesn't exist
- Required root pattern not resolved.
- Unexpected messageDialogKind: ${this.messageDialogKind}
- Unexpected messageReportKind: ${msgReportKind}
AI-assisted analysis of neoclide/coc.nvim@50e974d969 (2026-08-31).
Data as JSON: /api/errors/c8db0024ce771b96.
Report an issue: GitHub.