{"record":{"id":"6c58dad7ebe64dee","repo":"nocobase/nocobase","slug":"name-action-is-not-allowed","errorCode":null,"errorMessage":"${name} action is not allowed","messagePattern":"(.+?) action is not allowed","errorType":"exception","errorClass":null,"httpStatus":500,"severity":"error","filePath":"packages/core/resourcer/src/resource.ts","lineNumber":102,"sourceCode":"      excludes = except;\n    } else if (only.length > 0) {\n      excludes = Object.keys(actions).filter((name) => !only.includes(name));\n    }\n    this.except = excludes;\n    this.actions = Action.toInstanceMap(_.omit(actions, excludes), this);\n  }\n\n  getName() {\n    return this.options.name;\n  }\n\n  getExcept() {\n    return this.except;\n  }\n\n  addAction(name: ActionName, handler: HandlerType) {\n    if (this.except.includes(name)) {\n      throw new Error(`${name} action is not allowed`);\n    }\n    if (this.actions.has(name)) {\n      throw new Error(`${name} action already exists`);\n    }\n    const action = new Action(handler);\n    action.setName(name);\n    action.setResource(this);\n    action.middlewares.unshift(...this.middlewares);\n    this.actions.set(name, action);\n  }\n\n  getAction(action: ActionName) {\n    if (this.except.includes(action)) {\n      throw new Error(`${action} action is not allowed`);\n    }\n    if (!this.actions.has(action)) {\n      throw new Error(`${action} action does not exist`);\n    }","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/nocobase/nocobase/blob/fa42722fefe44265490dff2c27d79e2882bce4fa/packages/core/resourcer/src/resource.ts#L84-L120","documentation":"Resource.addAction() throws when the action name being registered is listed in the resource's `except` array. The `except` option blacklists specific actions on a resource, so registering or re-registering one of them is forbidden by design. It prevents handlers from being attached to actions that the resource explicitly disables.","triggerScenarios":"Calling resource.addAction(name, handler) where `name` is in the resource's `except` list, e.g. a resource defined with `except: ['destroy']` and later code attempting `resource.addAction('destroy', handler)`.","commonSituations":"Plugins or app bootstrap code registering default/extra actions on a resource that was configured with `except` (e.g. a collection configured to disallow 'destroy' or 'import'), or generic registration loops that register all CRUD actions without checking the resource's except list.","solutions":["Remove the action name from the resource's `except` option if the action should be allowed","Skip the action in registration code when it is in `resource.getExcept()`","Register the handler under a different custom action name not in the except list"],"exampleFix":"// before\n['list', 'get', 'create', 'update', 'destroy'].forEach((name) => resource.addAction(name, handlers[name]));\n// after\n['list', 'get', 'create', 'update', 'destroy'].forEach((name) => {\n  if (!resource.getExcept().includes(name)) resource.addAction(name, handlers[name]);\n});","handlingStrategy":"validation","validationCode":"if (resource.getExcept().includes(name)) {\n  // skip registration or log a warning instead of calling addAction\n  return;\n}\nresource.addAction(name, handler);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check `resource.getExcept()` before registering actions in generic registration loops","Centralize action registration in one module so except lists are respected consistently"],"tags":["resourcer","action-registration","blacklisted-action"],"backgroundTag":"action-not-allowed","analyzedSha":"fa42722fefe44265490dff2c27d79e2882bce4fa","analyzedAt":"2026-09-01T00:54:31.202Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}