{"record":{"id":"05a5d2759d56948d","repo":"hasura/graphql-engine","slug":"source-type-object-type-name-referenced-in-the-d","errorCode":null,"errorMessage":"Source type {object_type_name} referenced in the definition of relationship {relationship_name} is not defined ","messagePattern":"Source type (.+?) referenced in the definition of relationship (.+?) is not defined ","errorType":"validation","errorClass":"RelationshipError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/stages/relationships/error.rs","lineNumber":19,"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    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/relationships/error.rs#L1-L33","documentation":"A relationship definition exists for an object type name that is not present in the resolved types subgraph. The relationships stage looks up the source type of the relationship and fails, meaning the relationship file points at a type that was never defined (or is in a different subgraph/namespace). Note the trailing space in the message is cosmetic.","triggerScenarios":"A relationship block whose source object type name doesn't match any Qualified<CustomTypeName> in the types stage output: misspelled type name, type removed, or wrong subgraph/namespace qualification in the metadata.","commonSituations":"Renaming or deleting an object type without updating its relationships file; putting relationships in a different subgraph than the type; namespace mismatch between the relationship metadata and the type metadata.","solutions":["Check the object type spelling in the relationship metadata against the actual type definition","If the type was renamed, update the relationship's source type","Ensure type and relationship metadata live in (or reference) the same subgraph namespace","If the type should exist, verify the types stage ran successfully before relationships"],"exampleFix":"# before\nrelationships:\n  - sourceType: Usr   # type is defined as 'User'\n    name: Address\n# after\nrelationships:\n  - sourceType: User\n    name: Address","handlingStrategy":"validation","validationCode":"fn check_relationship_source_types(\n    types: &BTreeMap<Qualified<CustomTypeName>, ()>,\n    rels: &[Relationship],\n) -> Result<(), String> {\n    for r in rels {\n        if !types.contains_key(&r.source_type) {\n            return Err(format!(\"relationship source type {} undefined\", r.source_type));\n        }\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"downcast to RelationshipDefinedOnUnknownType and report the missing type name plus the relationship file for quick fixing","preventionTips":["When deleting a type, grep for relationships referencing it first","Use consistent namespace qualification between types and relationships","Validate types stage output before the relationships stage in build scripts"],"tags":["metadata","relationships","unknown-type","opendd","hasura-ddn"],"backgroundTag":"undefined-type-reference","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}