balderdashy/sails · error · UsageError

Could not JSON.parse() the provided `where` clause. Here is

Error message

Could not JSON.parse() the provided `where` clause. Here is the raw error: ${e.stack}

What it means

Error "Could not JSON.parse() the provided `where` clause. Here is the raw error: ${e.stack}" thrown in balderdashy/sails.

Source

Thrown at lib/hooks/blueprints/actionUtil.js:234

    req.options.criteria = req.options.criteria || {};
    req.options.criteria.blacklist = req.options.criteria.blacklist || ['limit', 'skip', 'sort', 'populate'];

    // Validate blacklist to provide a more helpful error msg.
    var blacklist = req.options.criteria && req.options.criteria.blacklist;
    if (blacklist && !_.isArray(blacklist)) {
      throw new Error('Invalid `req.options.criteria.blacklist`. Should be an array of strings (parameter names.)');
    }

    // Look for explicitly specified `where` parameter.
    var where = req.allParams().where;

    // If `where` parameter is a string, try to interpret it as JSON.
    // (If it cannot be parsed, throw a UsageError.)
    if (_.isString(where)) {
      try {
        where = JSON.parse(where);
      } catch (e) {
        throw flaverr({ name: 'UsageError' }, new Error('Could not JSON.parse() the provided `where` clause. Here is the raw error: '+e.stack));
      }
    }//>-•

    // If `where` has not been specified, but other unbound parameter variables
    // **ARE** specified, build the `where` option using them.
    if (!where) {

      // Prune params which aren't fit to be used as `where` criteria
      // to build a proper where query
      where = req.allParams();

      // Omit built-in runtime config (like query modifiers)
      where = _.omit(where, blacklist || ['limit', 'skip', 'sort']);

      // Omit any params that have `undefined` on the RHS.
      where = _.omit(where, function(p) {
        if (_.isUndefined(p)) { return true; }
      });

View on GitHub (pinned to 7b76422cc2)

When it happens

Trigger: Thrown at lib/hooks/blueprints/actionUtil.js:234 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/6338bce332a01b62. Report an issue: GitHub.