{"record":{"id":"4c575e69cbc20ac8","repo":"medusajs/medusa","slug":"42703","errorCode":"42703","errorMessage":"${userFriendlyMessage ?? err.message}","messagePattern":"\\$\\{userFriendlyMessage \\?\\? err\\.message\\}","errorType":"validation","errorClass":"MedusaError","httpStatus":400,"severity":"error","filePath":"packages/core/utils/src/dal/mikro-orm/db-error-mapper.ts","lineNumber":60,"sourceCode":"\n  if (\n    err instanceof NotNullConstraintViolationException ||\n    (err as any).code === \"23502\"\n  ) {\n    throw new MedusaError(\n      MedusaError.Types.INVALID_DATA,\n      `Cannot set field '${(err as any).column}' of ${upperCaseFirst(\n        (err as any).table.split(\"_\").join(\" \")\n      )} to null`\n    )\n  }\n\n  if (\n    err instanceof InvalidFieldNameException ||\n    (err as any).code === \"42703\"\n  ) {\n    const userFriendlyMessage = err.message.match(/(column.*)/)?.[0]\n    throw new MedusaError(\n      MedusaError.Types.INVALID_DATA,\n      userFriendlyMessage ?? err.message\n    )\n  }\n\n  if (\n    err instanceof ForeignKeyConstraintViolationException ||\n    (err as any).code === \"23503\"\n  ) {\n    const info = getConstraintInfo(err)\n    throw new MedusaError(\n      MedusaError.Types.NOT_FOUND,\n      `You tried to set relationship ${info?.keys.map(\n        (key, i) => `${key}: ${info.values[i]}`\n      )}, but such entity does not exist`\n    )\n  }\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/core/utils/src/dal/mikro-orm/db-error-mapper.ts#L42-L78","documentation":"PostgreSQL error 42703 (undefined_column) was raised by the database and re-thrown by Medusa's dbErrorMapper as a MedusaError of type INVALID_DATA. It means a query referenced a column that does not exist on the table, usually because the entity/model field name does not match the actual database schema (missing migration, renamed field, or a typo in a filter/selection). The mapper extracts the offending 'column ...' fragment from the raw driver message to surface it to you.","triggerScenarios":"Any repository/service operation (find, list, update, upsert, softDelete) that filters on, selects, or orders by a field whose column is absent from the table: e.g. productService.list({ where: { tag_col: x } }) when the column is tag_col_name, or after adding a new property to a model without running its migration.","commonSituations":"Adding/removing/renaming a data model property in packages/modules/* without generating and running the migration; passing internal/aliased property names instead of actual column names in raw filters; environment database out of sync with the code version; selecting a column dropped in a newer Medusa release.","solutions":["Read the extracted 'column \"x\" ...' fragment and check whether that column exists in the table (\\d table in psql) — then fix the field name in your query/filter to the real column name.","If the column is legitimately part of a new/changed model, generate the module migration (cd packages/modules/<module> && yarn migration:create) and run migrations so the schema matches the entities.","Verify you are passing database field names (snake_case columns) where raw filters require them, not camelCase model properties.","Ensure your database is migrated to the version of @medusajs/* packages your app runs (medusa db:migrate or the framework migration command)."],"exampleFix":"// before\nawait manager.find(Product, {\n  where: { material_col: \"wood\" }, // column \"material_col\" does not exist\n})\n\n// after\nawait manager.find(Product, {\n  where: { material: \"wood\" }, // matches the actual column defined by the model/migration\n})","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"import { MedusaError } from \"@medusajs/framework/utils\"\n\nfunction isInvalidDataError(err: unknown): err is MedusaError {\n  return err instanceof MedusaError && err.type === MedusaError.Types.INVALID_DATA\n}","tryCatchPattern":"try {\n  await repo.find(filters)\n} catch (err) {\n  if (err instanceof MedusaError && err.type === MedusaError.Types.INVALID_DATA) {\n    // inspect message for 'column \"x\" does not exist'; surface a field-level error\n  }\n  throw err\n}","preventionTips":["Run module migrations after every model change before starting the server.","Keep integration test databases recreated via the test runner so schema drift is caught early.","Use typed filter objects derived from the model rather than hand-written raw column strings."],"tags":["database","postgres","undefined-column","migration","mikro-orm"],"backgroundTag":"postgres-undefined-column","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}