{"record":{"id":"8b35e42301dae07c","repo":"medusajs/medusa","slug":"message-8b35e4","errorCode":null,"errorMessage":"${message}","messagePattern":"\\$\\{message\\}","errorType":"validation","errorClass":"MedusaError","httpStatus":400,"severity":"error","filePath":"packages/modules/search/src/providers/search-medusa/utils/query.ts","lineNumber":32,"sourceCode":"import type { MedusaSearchQueryOptions } from \"./options\"\nimport { IndexPlan, isSearchable } from \"./plan\"\n\nexport type HighlightPlan = {\n  pre_tag: string\n  post_tag: string\n  fields: { path: string; key: string }[]\n}\n\nexport type QueryPlan = {\n  query: IndexQuery\n  skip: number\n  take: number\n  options: MedusaSearchQueryOptions\n  highlight?: HighlightPlan\n}\n\nfunction fail(message: string): never {\n  throw new MedusaError(MedusaError.Types.NOT_ALLOWED, message)\n}\n\nfunction providerOptions(\n  input: SearchTypes.ProviderSearchQuery\n): MedusaSearchQueryOptions {\n  return (input.search_options?.provider_options?.[\"search-medusa\"] ??\n    {}) as MedusaSearchQueryOptions\n}\n\nfunction textRank(\n  input: SearchTypes.ProviderSearchQuery,\n  plan: IndexPlan\n): RankBy {\n  const fields =\n    input.search_options?.attributes_to_search_on ?? plan.searchable\n\n  if (!fields.length) {\n    fail(","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/modules/search/src/providers/search-medusa/utils/query.ts#L14-L50","documentation":"This is the query-planning error channel (query.ts fail()): textRank, clauses, boostWithTypoTolerance, buildHighlightPlan, fields, and buildQueryPlan throw NOT_ALLOWED for search queries the provider can't express — e.g. provider_options under \"search-medusa\" with unsupported ranking/boost/highlight/typo settings, or query shapes that don't map to the cloud query language.","triggerScenarios":"Passing search_options.provider_options[\"search-medusa\"] with invalid combinations (boost/typo-tolerance settings that conflict with index settings, highlight fields that aren't searchable, unknown ranking modifiers), or query parameters the plan builder cannot translate.","commonSituations":"Copy-pasting provider_options meant for another provider namespace; boosting non-searchable or non-indexed fields; requesting highlights on keyword-only fields; version drift after provider option keys were tightened.","solutions":["Check the exact message — it names the rejected option/field combination","Restrict provider_options to fields that are searchable in the index definition; remove highlights/boosts on non-searchable fields","Scope options under the \"search-medusa\" key only and remove options belonging to other providers"],"exampleFix":"// before\nsearch_options: {\n  provider_options: {\n    \"search-medusa\": { highlight: { fields: [\"id\"] } },\n  },\n}\n// after - highlight only searchable fields\nsearch_options: {\n  provider_options: {\n    \"search-medusa\": { highlight: { fields: [\"title\", \"description\"] } },\n  },\n}\n","handlingStrategy":"validation","validationCode":"function sanitizeProviderOptions(opts, searchableFields) {\n  const o = { ...opts }\n  if (o.highlight?.fields) {\n    o.highlight.fields = o.highlight.fields.filter((f) => searchableFields.includes(f))\n  }\n  return o\n}","typeGuard":"const isSearchableField = (f, searchable) => searchable.includes(f)","tryCatchPattern":"try { await search(...) } catch (e) { if (e instanceof MedusaError && e.type === \"not_allowed\" && /boost|highlight|typo|query/i.test(e.message)) { /* strip provider_options and retry plain */ } throw e }","preventionTips":["Namespace options under \"search-medusa\" only; never mix provider keys","Only boost/highlight fields marked searchable in the index","Keep provider_options in one shared, tested constant instead of ad-hoc inline objects"],"tags":["search","query-options","unsupported-feature","provider-options"],"backgroundTag":"invalid-query-options","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}