hasura/graphql-engine · error · RelationshipError

The field path provided in the {location:} of the relationsh

Error message

The field path provided in the {location:} of the relationship {relationship_name} on type {type_name} is empty

What it means

A field path supplied in a relationship (the message says which location, e.g. source or target mapping) resolved to an empty list of path segments, which is meaningless and rejected.

Source

Thrown at v3/crates/metadata-resolve/src/stages/object_relationships/error.rs:157

        relationship_name: RelationshipName,
        error: models::ModelsError, // ideally, this would return the more accurate
                                    // `ModelAggregateExpressionError` instead
    },
    #[error(
        "The source field '{source_field_name}' of type '{source_field_type}' in the relationship '{relationship_name}' on type '{source_type}' cannot be mapped to the target argument '{target_argument_name}' of type '{target_argument_type}' on the target model '{target_model_name}' because their types are incompatible"
    )]
    ModelArgumentTargetMappingTypeMismatch {
        source_type: Qualified<CustomTypeName>,
        relationship_name: RelationshipName,
        source_field_name: FieldName,
        source_field_type: QualifiedTypeReference,
        target_model_name: Qualified<ModelName>,
        target_argument_name: ArgumentName,
        target_argument_type: QualifiedTypeReference,
    },
    #[error("Relationship mappings from value expressions are not supported yet.")]
    ValueExpressionMappingsNotSupportedYet,
    #[error(
        "The field path provided in the {location:} of the relationship {relationship_name} on type {type_name} is empty"
    )]
    EmptyFieldPath {
        location: String,
        relationship_name: RelationshipName,
        type_name: Qualified<CustomTypeName>,
    },
    #[error(
        "Model fields cannot be used in command based relationship: {relationship_name:} on type {type_name:}"
    )]
    ModelFieldCannotBeUsedInCommandRelationship {
        relationship_name: RelationshipName,
        type_name: Qualified<CustomTypeName>,
    },
    #[error("Relationships with nested field paths are not supported yet.")]
    NestedFieldPathsNotSupportedYet,
    #[error("{0}")]
    CommandError(#[from] commands::CommandsError),

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Locate the location named in the message and fill in a real field name/path
  2. If the field is genuinely unused, remove the mapping entry entirely
  3. Validate generated metadata for empty strings before applying

Example fix

// before
field_mappings:
  - source: ""
    target: { model: authors, field: id }
// after
field_mappings:
  - source: author_id
    target: { model: authors, field: id }
Defensive patterns

Strategy: validation

Validate before calling

for (const m of rel.field_mappings ?? []) {
  if (!m.source || m.source.trim() === '') throw new Error('empty source field path');
  if (!m.target?.field || m.target.field.trim() === '') throw new Error('empty target field path');
}

Try / catch

try { await applyMetadata(md); } catch (e) { if (/field path .* is empty/.test(e.message)) { /* fill or remove the empty path */ } throw e; }

Prevention

When it happens

Trigger: Providing an empty string field name or an empty field-path array in a relationship mapping (e.g. `field: ""` or `path: []`).

Common situations: Templating/automation generating metadata with empty placeholders; hand-written YAML leaving a blank field value.

Related errors


AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28). Data as JSON: /api/errors/1871e64b58586f79. Report an issue: GitHub.