{"record":{"id":"6e4441b06aaa388d","repo":"hasura/graphql-engine","slug":"mapping-for-source-field-field-name-already-exis","errorCode":null,"errorMessage":"Mapping for source field {field_name} already exists in the relationship {relationship_name} on type {type_name}","messagePattern":"Mapping for source field (.+?) already exists in the relationship (.+?) on type (.+?)","errorType":"validation","errorClass":"RelationshipError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/stages/object_relationships/error.rs","lineNumber":77,"sourceCode":"    #[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(\n        \"target argument {argument_name} in argument mapping for relationship {relationship_name} on type {source_type} to command {command_name} is unknown.\"\n    )]\n    UnknownTargetCommandArgumentInRelationshipMapping {\n        source_type: Qualified<CustomTypeName>,\n        relationship_name: RelationshipName,\n        command_name: Qualified<CommandName>,\n        argument_name: ArgumentName,\n    },\n    #[error(\n        \"Mapping for source field {field_name} already exists in the relationship {relationship_name} on type {type_name}\"\n    )]\n    MappingExistsInRelationship {\n        type_name: Qualified<CustomTypeName>,\n        field_name: FieldName,\n        relationship_name: RelationshipName,\n    },\n    #[error(\n        \"The target argument {argument_name} of model {model_name} has been mapped more than once in the relationship {relationship_name} on type {type_name}\"\n    )]\n    ModelArgumentMappingExistsInRelationship {\n        argument_name: ArgumentName,\n        model_name: Qualified<ModelName>,\n        relationship_name: RelationshipName,\n        type_name: Qualified<CustomTypeName>,\n    },\n    #[error(\n        \"The target argument {argument_name} of command {command_name} has been mapped more than once in the relationship {relationship_name} on type {type_name}\"","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/object_relationships/error.rs#L59-L95","documentation":"The same source field is used in more than one field mapping within a single relationship. Each source field may only be mapped once per relationship.","triggerScenarios":"Defining two field mapping entries with identical source_field values on the same relationship (often via YAML anchors or duplicated blocks).","commonSituations":"Copy-paste duplication in metadata YAML/JSON; merging metadata files that each add a mapping for the same source field.","solutions":["Find duplicate source field entries in the relationship's field_mappings and keep only one","If you need to map the same source to multiple targets, that is not supported — remove the extra entry","Lint metadata for duplicate mapping keys before applying"],"exampleFix":"// before\nfield_mappings:\n  - source: author_id\n    target: { model: authors, field: id }\n  - source: author_id\n    target: { model: users, field: id }\n// after\nfield_mappings:\n  - source: author_id\n    target: { model: authors, field: id }","handlingStrategy":"validation","validationCode":"const sources = (rel.field_mappings ?? []).map(m => m.source);\nconst dupes = sources.filter((s, i) => sources.indexOf(s) !== i);\nif (dupes.length) throw new Error(`duplicate source fields: ${dupes}`);","typeGuard":null,"tryCatchPattern":"try { await applyMetadata(md); } catch (e) { if (/Mapping for source field .* already exists/.test(e.message)) { /* dedupe */ } throw e; }","preventionTips":["Dedupe mapping sources programmatically before apply","Avoid YAML anchors that duplicate mapping blocks"],"tags":["metadata","relationships","field-mapping","duplicate","validation"],"backgroundTag":"metadata-relationship-validation-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}