{"record":{"id":"1dfac8386c5b08f9","repo":"hasura/graphql-engine","slug":"target-field-field-name-in-field-mapping-for-rel","errorCode":null,"errorMessage":"target field {field_name} in field mapping for relationship {relationship_name} on type {source_type} to model {model_name} is unknown.","messagePattern":"target field (.+?) in field mapping for relationship (.+?) on type (.+?) to model (.+?) is unknown\\.","errorType":"validation","errorClass":"RelationshipError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/stages/object_relationships/error.rs","lineNumber":50,"sourceCode":"\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.\"\n    )]\n    UnknownTargetModelArgumentInRelationshipMapping {\n        source_type: Qualified<CustomTypeName>,\n        relationship_name: RelationshipName,\n        model_name: Qualified<ModelName>,\n        argument_name: ArgumentName,\n    },\n    #[error(","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/object_relationships/error.rs#L32-L68","documentation":"A relationship field mapping points at a target field that does not exist on the target model. The resolver verifies the `field_name` in each mapping against the target model's fields.","triggerScenarios":"Mapping to a target model field that is not defined on the target model (typo, renamed field, wrong model chosen as target).","commonSituations":"Target model schema changed (field renamed/removed) but relationship mappings weren't updated; mappings authored against a different version of the model.","solutions":["Confirm the target model in the mapping and inspect its actual fields","Correct the target field name in the field mapping","If the target field was removed, re-map to an existing field or drop the mapping"],"exampleFix":"// before\nfield_mappings:\n  - source: author_id\n    target: { model: authors, field: authorId } # model defines 'id'\n// after\nfield_mappings:\n  - source: author_id\n    target: { model: authors, field: id }","handlingStrategy":"validation","validationCode":"const modelFields = new Set(models[targetModel].fields.map(f => f.name));\nfor (const m of rel.field_mappings ?? []) {\n  if (!modelFields.has(m.target.field)) throw new Error(`unknown target field ${m.target.field} on model ${targetModel}`);\n}","typeGuard":null,"tryCatchPattern":"try { await applyMetadata(md); } catch (e) { if (/target field .* is unknown/.test(e.message)) { /* diff model fields vs mapping */ } throw e; }","preventionTips":["Regenerate model field lists whenever the underlying schema changes","Validate mappings against the live model schema in CI"],"tags":["metadata","relationships","field-mapping","model","validation"],"backgroundTag":"metadata-relationship-validation-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}