{"record":{"id":"c1809410cc56b414","repo":"hasura/graphql-engine","slug":"target-source-for-model-target-model-name-is","errorCode":null,"errorMessage":"target source for model '{target_model_name:}' is required to resolve predicate with relationships for {source_type_name:}","messagePattern":"target source for model '(.+?)' is required to resolve predicate with relationships for (.+?)","errorType":"validation","errorClass":"TypePredicateError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/types/error.rs","lineNumber":504,"sourceCode":"        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,\n    },\n    #[error(\"expected object type for field {field_name:} but field had type {field_type:}\")]\n    ExpectedObjectType {\n        field_type: QualifiedTypeReference,\n        field_name: Spanned<FieldName>,\n    },\n    #[error(\"object type {type_name:} not found\")]\n    ObjectTypeNotFound {","sourceCodeStart":486,"sourceCodeEnd":522,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/types/error.rs#L486-L522","documentation":"Resolving a predicate that spans a relationship requires knowing the target model's source, but the target model has no source (data connector) defined. Without the target source the resolver cannot build the cross-model query, so it reports that the target source is required.","triggerScenarios":"A relationship predicate whose target model is source-less (e.g. a command-backed or purely computed model without `source`); filtering through a relationship into a model that has no data connector attached.","commonSituations":"Target models that expose only commands (no tables); models intended as views or virtual types used accidentally as filter targets; metadata where sources were removed during refactor.","solutions":["Attach a source (dataConnectorName) to the target model named `target_model_name`, if it should be data-backed","If the target is intentionally source-less, don't filter through that relationship — filter after the command/relationship is resolved at the API layer","Rework the relationship to target a model that has a source"],"exampleFix":"# before\nmodels:\n  stats:               # command-only model, no source\nrelationships:\n  - name: stats\n    targetModel: stats\n# filter via 'stats' relationship -> error\n# after\nmodels:\n  stats:\n    source: {dataConnectorName: postgres}   # or filter elsewhere\n","handlingStrategy":"validation","validationCode":"// Only allow relationship predicates when the target model has a source\nif model.source.is_none() {\n    return Err(\"target model has no source; cannot resolve relationship predicate\".into());\n}","typeGuard":"fn has_source(m: &Model) -> bool {\n    m.source.is_some()\n}","tryCatchPattern":"if let Err(TypePredicateError::TargetSourceRequiredForRelationshipPredicate { target_model_name, .. }) = result {\n    // attach a source to the target model or filter without the relationship\n}","preventionTips":["Document which models are data-backed vs command-only","Never route filters through command-only models"],"tags":["relationship","predicate","source","model","metadata","hasura"],"backgroundTag":"missing-data-source","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}