medusajs/medusa · error · MedusaError

${message}

Error message

${message}

What it means

This is the index-plan error channel (plan.ts fail()): fieldType, assertIndexSupported, and toSearchDocument throw NOT_ALLOWED for index definitions the provider cannot build. Concrete rejections: vector fields declared as arrays or without positive dimensions, geo fields, unsupported field types, correlated array predicates, synonyms, and custom stop-word lists.

Source

Thrown at packages/modules/search/src/providers/search-medusa/utils/plan.ts:38

export type TypoToleranceSettings = {
  enabled: boolean
  min_word_size_for_one_typo: number
  min_word_size_for_two_typos: number
  disabled_on_attributes: Set<string>
}

export type IndexPlan = {
  fields: Map<string, PlannedField>
  schema: Record<string, AttributeSchema>
  searchable: string[]
  primary_key: string
  options: MedusaSearchIndexOptions
  typo_tolerance: TypoToleranceSettings
}

function fail(message: string): never {
  throw new MedusaError(MedusaError.Types.NOT_ALLOWED, message)
}

// Inspired by Meilisearch's own typo-tolerance defaults.
const DEFAULT_MIN_WORD_SIZE_FOR_ONE_TYPO = 5
const DEFAULT_MIN_WORD_SIZE_FOR_TWO_TYPOS = 9

function resolveTypoTolerance(
  settings: SearchTypes.SearchIndexSettings
): TypoToleranceSettings {
  const typo = settings.typo_tolerance
  return {
    enabled: typo?.enabled ?? true,
    min_word_size_for_one_typo:
      typo?.min_word_size_for_one_typo ?? DEFAULT_MIN_WORD_SIZE_FOR_ONE_TYPO,
    min_word_size_for_two_typos:
      typo?.min_word_size_for_two_typos ?? DEFAULT_MIN_WORD_SIZE_FOR_TWO_TYPOS,
    disabled_on_attributes: new Set(typo?.disabled_on_attributes ?? []),
  }

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. Remove synonyms and custom stop_words from the index settings
  2. Drop or replace geo fields (not supported by this provider)
  3. Fix vector fields: not array, with explicit positive dimensions (e.g. dimensions: 1536)
  4. Remove correlated: true from array fields or restructure the schema so predicates don't need per-element correlation

Example fix

// before
const settings = {
  synonyms: { phone: ["smartphone"] },
  stop_words: ["the", "a"],
}
// after
const settings = {
  typo_tolerance: { enabled: true }, // supported settings only
}
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED_TYPES = new Set(["keyword","text","integer","float","boolean","date","vector","object"])
function isIndexSupported(def) {
  if (def.settings?.synonyms) return false
  if (def.settings?.stop_words?.length) return false
  return Object.values(def.fields).every((f) =>
    f.type === "geo" || f.correlated ? false : SUPPORTED_TYPES.has(f.type)
  )
}

Type guard

const isSupportedFieldType = (t) =>
  ["keyword","text","integer","float","boolean","date","vector","object"].includes(t)

Try / catch

try { await createIndex(def) } catch (e) { if (e instanceof MedusaError && e.type === "not_allowed") { /* surface config error to operator: e.message says exactly which setting/field */ } throw e }

Prevention

When it happens

Trigger: Creating or loading a search index whose definition includes settings.synonyms, non-empty settings.stop_words, a field with type "geo", a vector field missing/duplicating dimensions, a correlated field, or any type outside keyword/text/integer/float/boolean/date/vector/object.

Common situations: Porting an index definition from Meilisearch (synonyms and stop words are common there) to the Medusa search provider; enabling geo filtering that this provider doesn't support; mis-declared vector (embedding) fields when adding semantic search.

Related errors


AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27). Data as JSON: /api/errors/1749fca675155388. Report an issue: GitHub.