medusajs/medusa · error · MedusaError

Invalid geo zone type: ${geoZone.type}

Error message

Invalid geo zone type: ${geoZone.type}

What it means

Thrown when creating/updating geo zones with a `type` that is not one of the recognized geo zone types (country, province, city, zip). The module validates the type against a required-properties map before persisting; unknown types have no entry and are rejected as INVALID_DATA.

Source

Thrown at packages/modules/fulfillment/src/services/fulfillment-module-service.ts:2161

    }
  }

  protected static validateGeoZones(
    geoZones: (
      | (Partial<FulfillmentTypes.CreateGeoZoneDTO> & { type: string })
      | (Partial<FulfillmentTypes.UpdateGeoZoneDTO> & { type: string })
    )[]
  ) {
    const requirePropForType = {
      country: ["country_code"],
      province: ["country_code", "province_code"],
      city: ["country_code", "province_code", "city"],
      zip: ["country_code", "province_code", "city", "postal_expression"],
    }

    for (const geoZone of geoZones) {
      if (!requirePropForType[geoZone.type]) {
        throw new MedusaError(
          MedusaError.Types.INVALID_DATA,
          `Invalid geo zone type: ${geoZone.type}`
        )
      }

      for (const prop of requirePropForType[geoZone.type]) {
        if (!geoZone[prop]) {
          throw new MedusaError(
            MedusaError.Types.INVALID_DATA,
            `Missing required property ${prop} for geo zone type ${geoZone.type}`
          )
        }
      }
    }
  }

  protected static normalizeListShippingOptionsForContextParams(
    filters: FulfillmentTypes.FilterableShippingOptionForContextProps,

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. Use only 'country' | 'province' | 'city' | 'zip'
  2. Map external type names to Medusa's types before calling the service
  3. Validate/whitelist the field at your API boundary

Example fix

// before
await service.createGeoZones([{ type: 'state', country_code: 'us' }])
// after
await service.createGeoZones([{ type: 'province', country_code: 'us', province_code: 'ca' }])
Defensive patterns

Strategy: type-guard

Validate before calling

const GEO_ZONE_TYPES = ['country','province','city','zip'] as const
if (!GEO_ZONE_TYPES.includes(zone.type)) throw new Error(`Invalid geo zone type: ${zone.type}`)

Type guard

type GeoZoneType = 'country' | 'province' | 'city' | 'zip'
const isGeoZoneType = (t: string): t is GeoZoneType => ['country','province','city','zip'].includes(t)

Prevention

When it happens

Trigger: createGeoZones / updateGeoZones with type values like 'region', 'state', postal', typos, or unvalidated user input from an API form.

Common situations: Admin custom UI passing free-text zone types; integrating external address taxonomies whose type names differ from Medusa's four canonical types.

Related errors


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