{"record":{"id":"e46447c2e04d15e3","repo":"balderdashy/sails","slug":"e-invalid","errorCode":"E_INVALID","errorMessage":"The action `' + identity + '` could not be registered.  It looks like a machine definition (actions2), but it could not be used to build an action.\\nDetails: '+e.stack","messagePattern":"The action `' \\+ identity \\+ '` could not be registered\\.  It looks like a machine definition \\(actions2\\), but it could not be used to build an action\\.\\\\nDetails: '\\+e\\.stack","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/app/private/controller/help-register-action.js","lineNumber":68,"sourceCode":"    throw flaverr({ name: 'userError', code: 'E_CONFLICT', identity: identity}, new Error('The action `' + identity + '` could not be registered because it conflicts with a previously-registered action.'));\n  }\n\n  // If the action is already a function, hope it's a req/res function\n  // and save it in our set of actions.\n  if (_.isFunction(action)) {\n    actions[identity] = action;\n\n  }\n  // Otherwise try to interpret it as an actions2 definition and build a Callable:\n  else {\n\n    try {\n      actions[identity] = machineAsAction(_.extend({\n        implementationSniffingTactic: sails.config.implementationSniffingTactic||undefined,\n      }, action));\n    }\n    catch (e) {\n      throw flaverr({ name: 'userError', code: 'E_INVALID', identity: identity, origError: e}, new Error('The action `' + identity + '` could not be registered.  It looks like a machine definition (actions2), but it could not be used to build an action.\\nDetails: '+e.stack));\n    }\n  }\n\n  // Set the _middlewareType, which is used when the log level is \"silly\" to\n  // identify what kind of a thing a route address is bound to.\n  actions[identity]._middlewareType = actions[identity]._middlewareType || 'ACTION: ' + identity;\n\n};\n","sourceCodeStart":50,"sourceCodeEnd":77,"githubUrl":"https://github.com/balderdashy/sails/blob/7b76422cc27823df033572bdda5c4910a68b697f/lib/app/private/controller/help-register-action.js#L50-L77","documentation":"When registerAction receives an object that looks like an actions2 machine definition instead of a function, Sails builds it with machineAsAction. If that construction fails (bad `fn`, invalid `inputs`/`exits`, missing properties), the error is wrapped with code E_INVALID including the underlying machine stack.","triggerScenarios":"Registering an actions2 object whose `fn` is missing/invalid, whose inputs/exits are malformed, or whose implementationSniffingTactic-adjacent fields are wrong, e.g. `sails.registerAction({ name: 'x', inputs: 42 })`-style definitions.","commonSituations":"Typos in machine definitions (fn key misspelled, wrong nesting); copying actions2 definitions across projects with incompatible machine versions; syntactically valid but semantically invalid inputs/exits.","solutions":["Read the `Details:` stack in the error to find the actual machine-construction failure.","Ensure the definition has a valid `fn` function and well-formed `inputs`/`exits` objects.","Pass a plain req/res function instead of a machine object if actions2 is not needed.","Check machineAsAction/Machine dependency versions for compatibility with the definition format."],"exampleFix":"// before\nsails.registerAction({ name: 'greet' }); // no fn\n// after\nsails.registerAction({ name: 'greet', fn: async function (inputs, exits) { return exits.success(); } });","handlingStrategy":"validation","validationCode":"if (typeof def === 'object' && def !== null) { if (typeof def.fn !== 'function') { throw new Error('actions2 definition for ' + identity + ' needs a fn'); } if (def.inputs && typeof def.inputs !== 'object') { throw new Error('inputs must be an object'); } }","typeGuard":"function isValidActions2(def) { return def && typeof def === 'object' && typeof def.fn === 'function' && (!def.inputs || typeof def.inputs === 'object') && (!def.exits || typeof def.exits === 'object'); }","tryCatchPattern":"try { sails.registerAction(def, identity); } catch (e) { if (e.code === 'E_INVALID') { sails.log.error('Bad actions2 definition for ' + identity + ':\\n' + (e.origError && e.origError.stack)); throw e; } throw e; }","preventionTips":["Ensure every actions2 definition has a valid `fn` (inputs, exits).","Validate machine definitions with a linter or schema test.","Keep machine/node-machine-kit versions consistent across projects.","Inspect e.origError/Details stack to pinpoint definition problems early."],"tags":["sails","actions2","machine","registration","validation"],"backgroundTag":"invalid-actions2-definition","analyzedSha":"7b76422cc27823df033572bdda5c4910a68b697f","analyzedAt":"2026-09-01T04:01:57.104Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}