{"record":{"id":"ac51a2a493f76c8e","repo":"hasura/graphql-engine","slug":"the-model-target-model-name-corresponding-to-ac51a2","errorCode":null,"errorMessage":"The model '{target_model_name:}' corresponding to the  relationship '{relationship_name:}' used in predicate for type '{type_name:}' is not defined","messagePattern":"The model '(.+?)' corresponding to the  relationship '(.+?)' used in predicate for type '(.+?)' is not defined","errorType":"validation","errorClass":"TypePredicateError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/types/error.rs","lineNumber":496,"sourceCode":"    NoBooleanExpressionFields {\n        field_name: Spanned<FieldName>,\n        type_name: Qualified<CustomTypeName>,\n    },\n    #[error(\n        \"relationship '{relationship_name}' is used in predicate but does not exist for type '{type_name}'\"\n    )]\n    UnknownRelationshipInTypePredicate {\n        relationship_name: Spanned<RelationshipName>,\n        type_name: Qualified<CustomTypeName>,\n    },\n    #[error(\n        \"relationship '{relationship_name}' is used in predicate but does not exist in comparableRelationships in boolean expression '{boolean_expression_type_name}'\"\n    )]\n    RelationshipNotComparableInTypePredicate {\n        relationship_name: Spanned<RelationshipName>,\n        boolean_expression_type_name: Qualified<CustomTypeName>,\n    },\n    #[error(\n        \"The model '{target_model_name:}' corresponding to the  relationship '{relationship_name:}' used in predicate for type '{type_name:}' is not defined\"\n    )]\n    UnknownModelUsedInRelationshipTypePredicate {\n        type_name: Qualified<CustomTypeName>,\n        target_model_name: Qualified<ModelName>,\n        relationship_name: RelationshipName,\n    },\n    #[error(\n        \"target source for model '{target_model_name:}' is required to resolve predicate with relationships for {source_type_name:}\"\n    )]\n    TargetSourceRequiredForRelationshipPredicate {\n        source_type_name: Qualified<CustomTypeName>,\n        target_model_name: Qualified<ModelName>,\n    },\n    #[error(\"{error:} in type {type_name:}\")]\n    TypeMappingCollectionError {\n        type_name: Qualified<CustomTypeName>,\n        error: TypeMappingCollectionError,","sourceCodeStart":478,"sourceCodeEnd":514,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/types/error.rs#L478-L514","documentation":"A relationship used inside a type predicate points to a target model that is not defined in the resolved metadata. The resolver must load the target model to translate the relationship predicate; if `target_model_name` doesn't resolve, it fails with this error.","triggerScenarios":"Relationship predicate referencing a model that was deleted, renamed, or lives in a subgraph not being resolved; qualified model-name prefix mismatch; typo in the relationship's target model.","commonSituations":"Renaming/removing models without updating relationships that point at them; multi-subgraph setups where the target model is in another subgraph that isn't linked; metadata file for the target model not included in the build.","solutions":["Search metadata for `target_model_name` — confirm a model with that qualified name exists","Fix the relationship's target model reference (name or subgraph prefix), or restore/re-declare the model","Ensure the subgraph containing the target model is included in the build/link graph"],"exampleFix":"# before\nrelationships:\n  - name: articles\n    targetModel: article   # model is named 'articles' elsewhere\n# after\nrelationships:\n  - name: articles\n    targetModel: articles\n","handlingStrategy":"validation","validationCode":"// Ensure the relationship's target model exists before resolving predicates\nif !metadata.models.contains_key(&relationship.target_model) {\n    return Err(format!(\"target model {} undefined\", relationship.target_model));\n}","typeGuard":"fn target_model_exists<'a>(md: &'a Metadata, m: &Qualified<ModelName>) -> Option<&'a Model> {\n    md.models.get(m)\n}","tryCatchPattern":"if let Err(TypePredicateError::UnknownModelUsedInRelationshipTypePredicate { target_model_name, .. }) = result {\n    return Err(format!(\"define or fix reference to model {target_model_name}\"));\n}","preventionTips":["Delete/update all relationship references when removing or renaming models","Validate cross-model references in CI metadata checks"],"tags":["relationship","model-not-found","predicate","metadata","hasura"],"backgroundTag":"model-not-found","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}