{"record":{"id":"aa07a5950cc8bf8a","repo":"hasura/graphql-engine","slug":"multiple-relationships-named-relationship-name-d","errorCode":null,"errorMessage":"Multiple relationships named {relationship_name} defined for type {object_type_name}","messagePattern":"Multiple relationships named (.+?) defined for type (.+?)","errorType":"validation","errorClass":"RelationshipError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/stages/relationships/error.rs","lineNumber":13,"sourceCode":"use crate::types::error::ContextualError;\nuse crate::types::subgraph::Qualified;\nuse open_dds::relationships::RelationshipName;\nuse open_dds::types::CustomTypeName;\n\n#[derive(Debug, thiserror::Error)]\npub enum RelationshipError {\n    #[error(\"Relationship {relationship_name} could not be found for type {object_type_name}\")]\n    RelationshipNotFound {\n        object_type_name: Qualified<CustomTypeName>,\n        relationship_name: RelationshipName,\n    },\n    #[error(\"Multiple relationships named {relationship_name} defined for type {object_type_name}\")]\n    DuplicateRelationshipForType {\n        object_type_name: Qualified<CustomTypeName>,\n        relationship_name: RelationshipName,\n    },\n\n    #[error(\n        \"Source type {object_type_name} referenced in the definition of relationship {relationship_name} is not defined \"\n    )]\n    RelationshipDefinedOnUnknownType {\n        relationship_name: RelationshipName,\n        object_type_name: Qualified<CustomTypeName>,\n    },\n}\n\nimpl ContextualError for RelationshipError {\n    fn create_error_context(&self) -> Option<error_context::Context> {\n        None\n    }","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/relationships/error.rs#L1-L31","documentation":"The relationships stage found two relationships with the same name declared on the same qualified object type. Relationship names must be unique per type, so the resolver cannot disambiguate which one to use and errors out. This is a metadata authoring/validation error, not a runtime data error.","triggerScenarios":"Two relationship entries with identical name on the same object type in the OpenDD metadata (duplicate YAML keys, copy-pasted relationship blocks, or merging two metadata files that both define the relationship).","commonSituations":"Copy-pasting a relationship block and forgetting to change the name; merging branches that both added the same relationship; YAML anchors accidentally duplicating entries.","solutions":["Find the duplicate entries for the named type and relationship in metadata files and delete or rename one","If the duplicates come from a merge conflict, resolve the conflict keeping a single definition","Run metadata validation/lint before apply to catch duplicates early"],"exampleFix":"# before\nUser:\n  relationships:\n    - name: Address\n      targetEntity: Address\n    - name: Address\n      targetEntity: SecondaryAddress\n# after\nUser:\n  relationships:\n    - name: Address\n      targetEntity: Address\n    - name: SecondaryAddress\n      targetEntity: SecondaryAddress","handlingStrategy":"validation","validationCode":"fn assert_unique_relationships(rels: &[Relationship]) -> Result<(), String> {\n    let mut seen = HashSet::new();\n    for r in rels {\n        if !seen.insert(r.name.clone()) {\n            return Err(format!(\"duplicate relationship: {}\", r.name.0));\n        }\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"catch duplicates during metadata lint: if let Some(RelationshipError::DuplicateRelationshipForType { .. }) = err.downcast_ref() { fail CI with file/line hints }","preventionTips":["Lint for duplicate names per object type in pre-commit","Avoid YAML anchors that duplicate relationship blocks wholesale","Review merge conflicts in relationships sections carefully"],"tags":["metadata","relationships","duplicate","opendd","hasura-ddn"],"backgroundTag":"duplicate-metadata-definition","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}