{"record":{"id":"24f97a206b7b5dce","repo":"medusajs/medusa","slug":"message-24f97a","errorCode":null,"errorMessage":"${message}","messagePattern":"\\$\\{message\\}","errorType":"validation","errorClass":"MedusaError","httpStatus":400,"severity":"error","filePath":"packages/modules/search/src/providers/search-medusa/utils/facets.ts","lineNumber":31,"sourceCode":"  { type: \"range\" }\n>\ntype ValueFacetRequest = {\n  field: string\n  type?: \"value\"\n  limit?: number\n  sort?: \"count\" | \"alpha\"\n  query?: string\n}\n\nexport type FacetQuery = {\n  field: string\n  request: RangeFacetRequest | ValueFacetRequest\n  range?: RangeFacetRequest[\"ranges\"][number]\n  query: IndexQuery\n}\n\nfunction fail(message: string): never {\n  throw new MedusaError(MedusaError.Types.NOT_ALLOWED, message)\n}\n\nfunction and(filters: (Filter | undefined)[]): Filter | undefined {\n  const present = filters.filter((item): item is Filter => !!item)\n  if (!present.length) {\n    return undefined\n  }\n  return present.length === 1 ? present[0] : [\"And\", present]\n}\n\nexport function buildFacetQueries(\n  input: SearchTypes.ProviderSearchQuery,\n  plan: IndexPlan\n): FacetQuery[] {\n  const requests = (input.search_options?.facets ?? []) as\n    | SearchTypes.SearchFacetRequest[]\n  const base = toSearchFilter(input.filters, plan)\n  const result: FacetQuery[] = []","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/modules/search/src/providers/search-medusa/utils/facets.ts#L13-L49","documentation":"This is the facet-building error channel of the search-medusa provider: buildFacetQueries calls fail() with a NOT_ALLOWED MedusaError for facet requests the provider cannot serve. Known messages: 'Unknown facet field \"<name>\"' (field not in the index plan) and rejection of type \"stats\" facets because the cloud service does not expose min/max aggregates.","triggerScenarios":"Passing a facet request in search_options.facets referencing a field not defined in the index schema (or not facetable/planned), or sending { type: \"stats\" } facets, which the Medusa cloud service cannot compute.","commonSituations":"Requesting facets on a field that exists on the model but was not added to the index definition; renaming/removing an index field while the storefront still requests the old facet; migrating a storefront from Meilisearch-style stats facets (price min/max) to Medusa search.","solutions":["Only request facet fields that exist in the index plan/definition; add the missing field as facetable in the index settings","Replace stats facets with range facets (e.g. explicit price buckets), which the provider supports","Keep the storefront facet list in sync with the index schema after model changes"],"exampleFix":"// before\nsearch_options: { facets: [{ field: \"price\", type: \"stats\" }] }\n// after\nsearch_options: {\n  facets: [\n    {\n      field: \"price\",\n      type: \"range\",\n      ranges: [{ to: 50 }, { from: 50, to: 100 }, { from: 100 }],\n    },\n  ],\n}\n","handlingStrategy":"validation","validationCode":"const indexFields = new Set([...]) // derived from index definition\nconst safeFacets = requestedFacets.filter(\n  (f) => indexFields.has(f.field) && f.type !== \"stats\"\n)","typeGuard":"const isSupportedFacet = (f, indexFields) =>\n  indexFields.has(f.field) &&\n  f.type !== \"stats\" &&\n  (f.type !== \"range\" || Array.isArray(f.ranges))","tryCatchPattern":"try { await search(...) } catch (e) { if (e instanceof MedusaError && e.type === \"not_allowed\" && /facet/i.test(e.message)) { return search(..., { facets: [] }) } throw e }","preventionTips":["Derive the storefront facet list from the index definition, not hardcoded strings","Use range facets instead of stats facets","Re-sync facet configs whenever index settings change"],"tags":["search","facets","unsupported-feature","schema-mismatch"],"backgroundTag":"unsupported-facet-request","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}