nocobase/nocobase · error

${action} action does not exist

Error message

${action} action does not exist

What it means

Resource.getAction() throws when the requested action name is not registered on the resource at all (the actions Map has no such key). Every resource action must be registered via addAction (or inherited defaults) before it can be resolved.

Source

Thrown at packages/core/resourcer/src/resource.ts:119

    if (this.except.includes(name)) {
      throw new Error(`${name} action is not allowed`);
    }
    if (this.actions.has(name)) {
      throw new Error(`${name} action already exists`);
    }
    const action = new Action(handler);
    action.setName(name);
    action.setResource(this);
    action.middlewares.unshift(...this.middlewares);
    this.actions.set(name, action);
  }

  getAction(action: ActionName) {
    if (this.except.includes(action)) {
      throw new Error(`${action} action is not allowed`);
    }
    if (!this.actions.has(action)) {
      throw new Error(`${action} action does not exist`);
    }
    return this.actions.get(action);
  }
}

export default Resource;

View on GitHub (pinned to fa42722fef)

Solutions

  1. Register the action: `resource.addAction(name, handler)` (or define it via the resourcer's define/registration path)
  2. Verify the action name spelling in the request path and in the registration code
  3. Ensure the plugin that supplies the action is enabled and loaded before the request

Example fix

// before
const action = resourcer.getResource('users').getAction('export'); // not registered
// after
resource.addAction('export', exportHandler);
const action = resource.getAction('export');
Defensive patterns

Strategy: try-catch

Validate before calling

if (!resource.actions.has(actionName)) {
  // register the action or return a 404 before lookup
}

Try / catch

try {
  const action = resource.getAction(actionName);
} catch (e) {
  if (e.message.endsWith('action does not exist')) {
    ctx.status = 404; // action missing: register it or fix the name
  } else throw e;
}

Prevention

When it happens

Trigger: Resourcer.getAction(resource, actionName) with an action name never registered, e.g. calling resource.getAction('export') when only the default CRUD actions were registered, or a typo'd action name in an HTTP route like /api/users:listt.

Common situations: Misspelled action in client request URL, custom action registered on a different resource than requested, plugin providing the action not loaded/enabled, or calling getAction before plugin registration completes.

Related errors


AI-assisted analysis of nocobase/nocobase@fa42722fef (2026-09-01). Data as JSON: /api/errors/8f74bde844e27a7d. Report an issue: GitHub.