{"record":{"id":"e97b73ef561fcacf","repo":"gatsbyjs/gatsby","slug":"a-regexp-instance-is-only-valid-for-regex-and-gl","errorCode":null,"errorMessage":"A RegExp instance is only valid for $regex and $glob comparators","messagePattern":"A RegExp instance is only valid for \\$regex and \\$glob comparators","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/gatsby/src/datastore/in-memory/indexing.ts","lineNumber":828,"sourceCode":"      // Nothing is lt/gt null\n      return undefined\n    }\n\n    // This is an edge case and this value should be directly indexed\n    // For `lte`/`gte` this should only return nodes for `null`, not a \"range\"\n    return filterCache.byValue.get(filterValue)\n  }\n\n  if (Array.isArray(filterValue)) {\n    throw new Error(\n      \"Array is an invalid filter value for the `\" + op + \"` comparator\"\n    )\n  }\n\n  if (filterValue instanceof RegExp) {\n    // This is most likely an internal error, although it is possible for\n    // users to talk to this API more directly.\n    throw new Error(\n      `A RegExp instance is only valid for $regex and $glob comparators`\n    )\n  }\n\n  if (op === `$lt`) {\n    // First try a direct approach. If a value is queried that also exists then\n    // we can prevent a binary search through the whole list, O(1) vs O(log n)\n\n    const ranges = filterCache.meta.valueRangesAsc\n    const nodes = filterCache.meta.nodesByValueAsc\n\n    const range = ranges!.get(filterValue)\n    if (range) {\n      const arr = nodes!.slice(0, range[0])\n      arr.sort(sortByIds)\n      // elemMatch can cause a node to appear in multiple buckets so we must dedupe\n      if (wasElemMatch) {\n        expensiveDedupeInline(arr)","sourceCodeStart":810,"sourceCodeEnd":846,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/e85d62f1779e353eaac1753211629a26d123e26c/packages/gatsby/src/datastore/in-memory/indexing.ts#L810-L846","documentation":"Late-stage guard in getNodesFromCacheByValue: after special-cased operators, a filter value that is a RegExp appears under a comparator other than $regex/$glob. Since RegExp cannot be an index key, this is rejected — most likely an internal misuse of the cache API.","triggerScenarios":"Thrown at packages/gatsby/src/datastore/in-memory/indexing.ts:828 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use RegExp values only with $regex or $glob comparators","Convert regex intentions to a $regex filter statement","Report as a Gatsby bug if it occurs with a plain GraphQL query"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e85d62f1779e353eaac1753211629a26d123e26c","analyzedAt":"2026-08-26T17:50:09.662Z","contentChangedAt":"2026-08-26T17:50:09.662Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}