medusajs/medusa · error · MedusaError

Cross-module join for "${join.target.table}" cannot be its o

Error message

Cross-module join for "${join.target.table}" cannot be its own parent.

What it means

Cross-module join validation: a join whose declared parent is the same as its own target table would create a self-referential cycle the resolver cannot order, so it is rejected.

Source

Thrown at packages/core/utils/src/dal/mikro-orm/cross-module-query/helpers.ts:178

  for (const join of crossModuleJoins) {
    if (targetTables.has(join.target.table)) {
      throw new MedusaError(
        MedusaError.Types.INVALID_DATA,
        `Duplicate cross-module join target table "${join.target.table}". Each join must target a unique table.`
      )
    }

    targetTables.add(join.target.table)
  }

  for (const join of crossModuleJoins) {
    if (!join.parent) {
      continue
    }

    if (join.parent === join.target.table) {
      throw new MedusaError(
        MedusaError.Types.INVALID_DATA,
        `Cross-module join for "${join.target.table}" cannot be its own parent.`
      )
    }

    if (!targetTables.has(join.parent)) {
      throw new MedusaError(
        MedusaError.Types.INVALID_DATA,
        `Cross-module join for "${join.target.table}" references unknown parent target table "${join.parent}".`
      )
    }
  }
}

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. Set the parent to the actual driving table of the join, or omit `parent` when the join hangs off the root
  2. Fix the generator that defaults parent to target.table

Example fix

// before
{ target: { table: "price" }, parent: "price" }
// after
{ target: { table: "price" } } // joins off the root entity
Defensive patterns

Strategy: validation

Validate before calling

for (const j of joins) if (j.parent === j.target.table) throw new Error(`self-parent join on ${j.target.table}`)

Prevention

When it happens

Trigger: A join spec where `join.parent === join.target.table`, e.g. { target: { table: "price" }, parent: "price" }, typically from programmatically derived parents defaulting to the same table.

Common situations: Auto-generated join configs that fall back to the current table when no parent is detected.

Related errors


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