{"record":{"id":"1455c03e4a730590","repo":"hasura/graphql-engine","slug":"relationship-relationship-name-could-not-be-foun","errorCode":null,"errorMessage":"Relationship {relationship_name} could not be found for type {object_type_name}","messagePattern":"Relationship (.+?) could not be found for type (.+?)","errorType":"validation","errorClass":"RelationshipError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/stages/relationships/error.rs","lineNumber":8,"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}","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/relationships/error.rs#L1-L26","documentation":"Thrown by the metadata-resolve relationships stage when an OpenDD relationship is referenced (e.g. from a model command or another metadata object) but no relationship with that name is defined on the specified custom object type. Resolution walks the types subgraph and fails to find the relationship entry, so metadata resolution aborts. It almost always indicates a dangling reference after a rename or deletion in the metadata files.","triggerScenarios":"Metadata files reference a relationship by name on a Qualified<CustomTypeName> (e.g. a model relationship entry or command argument mapping) that does not exist in the object type's relationships map. Typical triggers: renaming a relationship in types but not in dependent metadata, typos in the relationship name, or applying only part of a metadata change set.","commonSituations":"Splitting/renaming relationships across PRs where the referencing file lands first; copying metadata between subgraphs with different type definitions; YAML/JSON indentation mistakes that silently drop the relationships block.","solutions":["Grep all metadata files for the exact relationship name shown in the error and fix the typo or stale reference","If the relationship was renamed, update the referencing object (model/command) to the new name","If the relationship was deleted intentionally, remove the now-dangling reference","Re-run metadata resolve/build to confirm the types subgraph now contains the relationship"],"exampleFix":"# before\nobjects:\n  User:\n    relationships:\n      - name: Adress   # typo; referencing metadata says 'Address'\n        targetEntity: Address\n# after\nobjects:\n  User:\n    relationships:\n      - name: Address\n        targetEntity: Address","handlingStrategy":"validation","validationCode":"// before resolving/apply: assert every referenced relationship exists\nfn check_relationship_refs(\n    types: &BTreeMap<Qualified<CustomTypeName>, ObjectTypeWithRelationships>,\n    refs: &[(Qualified<CustomTypeName>, RelationshipName)],\n) -> Result<(), String> {\n    for (ty, rel) in refs {\n        let found = types.get(ty)\n            .and_then(|t| t.relationships.iter().find(|r| &r.name == rel));\n        if found.is_none() {\n            return Err(format!(\"relationship {rel} not found on type {ty}\"));\n        }\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = resolve_metadata(&metadata) {\n    if let Some(RelationshipError::RelationshipNotFound { object_type_name, relationship_name }) = e.downcast_ref() {\n        eprintln!(\"stale relationship ref: {relationship_name} on {object_type_name}\");\n    }\n}","preventionTips":["Run metadata apply in CI with validation before deploy","Grep for a relationship name across all metadata files before renaming or deleting it","Keep types and their dependents in the same metadata change/PR"],"tags":["metadata","relationships","opendd","hasura-ddn","resolution"],"backgroundTag":"dangling-metadata-reference","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}