{"record":{"id":"3a2df8a542eb8658","repo":"balderdashy/sails","slug":"e-non-fn-policy","errorCode":"E_NON_FN_POLICY","errorMessage":"Attempted to register action middleware(s) (aka policies) for `' + actionsGlobKey + '` but one or more provided action middlewares (policies) was not a function.","messagePattern":"Attempted to register action middleware\\(s\\) \\(aka policies\\) for `' \\+ actionsGlobKey \\+ '` but one or more provided action middlewares \\(policies\\) was not a function\\.","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/app/register-action-middleware.js","lineNumber":48,"sourceCode":" */\n\nmodule.exports = function registerActionMiddleware(middleware, actionsGlobKey) {\n\n  var sails = this;\n\n  // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n  // FUTURE: explore how we might extend machine-as-action or implement\n  // something entirely new (e.g. `machine-as-middleware`) that is kinda\n  // like machine-as-action, but where the success response calls `next`)\n  // This would be so that  machine defs can be registered as middleware?\n  // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n\n  if (!_.isArray(middleware)) {\n    middleware = [middleware];\n  }\n\n  if (!_.all(middleware, _.isFunction)) {\n    throw flaverr({ name: 'userError', code: 'E_NON_FN_POLICY' }, new Error('Attempted to register action middleware(s) (aka policies) for `' + actionsGlobKey + '` but one or more provided action middlewares (policies) was not a function.'));\n  }\n\n  // Get or create the array for this glob key.\n  var existingActionMiddlewareRegisteredForGlobKey = sails._actionMiddleware[actionsGlobKey] || [];\n\n  // Add these middlewares to the array.\n  existingActionMiddlewareRegisteredForGlobKey = existingActionMiddlewareRegisteredForGlobKey.concat(middleware);\n\n  // Assign the array back to our `_actionMiddleware` dictionary.\n  sails._actionMiddleware[actionsGlobKey] = existingActionMiddlewareRegisteredForGlobKey;\n\n};\n","sourceCodeStart":30,"sourceCodeEnd":61,"githubUrl":"https://github.com/balderdashy/sails/blob/7b76422cc27823df033572bdda5c4910a68b697f/lib/app/register-action-middleware.js#L30-L61","documentation":"Error \"Attempted to register action middleware(s) (aka policies) for `' + actionsGlobKey + '` but one or more provided action middlewares (policies) was not a function.\" thrown in balderdashy/sails.","triggerScenarios":"Thrown at lib/app/register-action-middleware.js:48 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7b76422cc27823df033572bdda5c4910a68b697f","analyzedAt":"2026-09-01T04:01:57.104Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}