{"record":{"id":"e921fae5577076ce","repo":"hasura/graphql-engine","slug":"source-field-field-name-in-field-mapping-for-rel","errorCode":null,"errorMessage":"source field {field_name} in field mapping for relationship {relationship_name} on type {source_type} is unknown.","messagePattern":"source field (.+?) in field mapping for relationship (.+?) on type (.+?) is unknown\\.","errorType":"validation","errorClass":"RelationshipError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/stages/object_relationships/error.rs","lineNumber":42,"sourceCode":"    #[error(\n        \"unknown target model {model_name:} used in relationship {relationship_name:} on type {type_name:}\"\n    )]\n    UnknownTargetModelUsedInRelationship {\n        type_name: Qualified<CustomTypeName>,\n        relationship_name: RelationshipName,\n        model_name: Qualified<ModelName>,\n    },\n\n    #[error(\n        \"unknown target command {command_name:} used in relationship {relationship_name:} on type {type_name:}\"\n    )]\n    UnknownTargetCommandUsedInRelationship {\n        type_name: Qualified<CustomTypeName>,\n        relationship_name: RelationshipName,\n        command_name: Qualified<CommandName>,\n    },\n\n    #[error(\n        \"source field {field_name} in field mapping for relationship {relationship_name} on type {source_type} is unknown.\"\n    )]\n    UnknownSourceFieldInRelationshipMapping {\n        source_type: Qualified<CustomTypeName>,\n        relationship_name: RelationshipName,\n        field_name: FieldName,\n    },\n    #[error(\n        \"target field {field_name} in field mapping for relationship {relationship_name} on type {source_type} to model {model_name} is unknown.\"\n    )]\n    UnknownTargetFieldInRelationshipMapping {\n        source_type: Qualified<CustomTypeName>,\n        relationship_name: RelationshipName,\n        model_name: Qualified<ModelName>,\n        field_name: FieldName,\n    },\n    #[error(\n        \"target argument {argument_name} in argument mapping for relationship {relationship_name} on type {source_type} to model {model_name} is unknown.\"","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/object_relationships/error.rs#L24-L60","documentation":"Indicates that a relationship's field mapping references a source field that does not exist on the source custom type. The resolver checks every field mapping's source field against the fields of the type that declares the relationship.","triggerScenarios":"Adding a field mapping like `{ source_field: id, target: ... }` where `id` is not a field declared on the source type; renaming a type field without updating its relationship mappings.","commonSituations":"Typos in source field names; schema drift after renaming or removing fields on the custom type; mappings copied from another type whose fields differ.","solutions":["Check the field mapping entries of the relationship and confirm each source_field exists on the source type","Fix any typo or stale field name in the mapping","If the field was renamed, update the mapping to the new name or remove the mapping entry"],"exampleFix":"// before\ntype: article\nfields: [id, title]\nrelationships:\n  author:\n    field_mappings:\n      - source: author_id   # not a field on article\n        target: { model: authors, field: id }\n// after\nfields: [id, title, author_id]\nrelationships:\n  author:\n    field_mappings:\n      - source: author_id\n        target: { model: authors, field: id }","handlingStrategy":"validation","validationCode":"const typeFields = new Set(Object.keys(metadata.types[srcType].fields));\nfor (const m of rel.field_mappings ?? []) {\n  if (!typeFields.has(m.source)) throw new Error(`unknown source field ${m.source} on ${srcType}`);\n}","typeGuard":null,"tryCatchPattern":"try { await applyMetadata(md); } catch (e) { if (/source field .* is unknown/.test(e.message)) { /* list type fields vs mappings */ } throw e; }","preventionTips":["Keep field mappings adjacent to the type definition in the same file/repo","Write a pre-apply schema cross-check script for source fields"],"tags":["metadata","relationships","field-mapping","validation"],"backgroundTag":"metadata-relationship-validation-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}