balderdashy/sails · error

E_NON_FN_POLICY

E_NON_FN_POLICY

Error message

Attempted to register action middleware(s) (aka policies) for `' + actionsGlobKey + '` but one or more provided action middlewares (policies) was not a function.

What it means

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.

Source

Thrown at lib/app/register-action-middleware.js:48

 */

module.exports = function registerActionMiddleware(middleware, actionsGlobKey) {

  var sails = this;

  // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  // FUTURE: explore how we might extend machine-as-action or implement
  // something entirely new (e.g. `machine-as-middleware`) that is kinda
  // like machine-as-action, but where the success response calls `next`)
  // This would be so that  machine defs can be registered as middleware?
  // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

  if (!_.isArray(middleware)) {
    middleware = [middleware];
  }

  if (!_.all(middleware, _.isFunction)) {
    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.'));
  }

  // Get or create the array for this glob key.
  var existingActionMiddlewareRegisteredForGlobKey = sails._actionMiddleware[actionsGlobKey] || [];

  // Add these middlewares to the array.
  existingActionMiddlewareRegisteredForGlobKey = existingActionMiddlewareRegisteredForGlobKey.concat(middleware);

  // Assign the array back to our `_actionMiddleware` dictionary.
  sails._actionMiddleware[actionsGlobKey] = existingActionMiddlewareRegisteredForGlobKey;

};

View on GitHub (pinned to 7b76422cc2)

When it happens

Trigger: Thrown at lib/app/register-action-middleware.js:48 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of balderdashy/sails@7b76422cc2 (2026-09-01). Data as JSON: /api/errors/3a2df8a542eb8658. Report an issue: GitHub.