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/parse-blueprint-options.js:135

        var where = {};

        // For `findOne`, set "where" to just look at the primary key.
        if (blueprint === 'findOne') {
          where[Model.primaryKey] = req.param('id');
          return where;
        }

        // Look for explicitly specified `where` parameter.
        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, ['limit', 'skip', 'sort', 'populate', 'select', 'omit']);

          // 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/parse-blueprint-options.js:135 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/59d5566db2d65082. Report an issue: GitHub.