{"record":{"id":"96766f4093014119","repo":"hasura/graphql-engine","slug":"unknown-field-field-name-for-type-type-name","errorCode":null,"errorMessage":"unknown field '{field_name}' for type '{type_name}' used in target mapping for relationship '{relationship_name}'","messagePattern":"unknown field '(.+?)' for type '(.+?)' used in target mapping for relationship '(.+?)'","errorType":"validation","errorClass":"TypePredicateError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/types/error.rs","lineNumber":413,"sourceCode":"    TypePredicateFieldNotFoundInBooleanExpression {\n        field_name: Spanned<FieldName>,\n        type_name: Qualified<CustomTypeName>,\n        boolean_expression_type: Qualified<CustomTypeName>,\n    },\n\n    #[error(\"field '{field_name:}' could not be found in field mappings for type '{type_name:}'\")]\n    UnknownFieldInFieldMappings {\n        field_name: Spanned<FieldName>,\n        type_name: Qualified<CustomTypeName>,\n    },\n    #[error(\n        \"field '{field_name:}' of type '{type_name:}' is an array type and cannot be used in a nested field predicate\"\n    )]\n    ArrayFieldInNestedFieldPredicate {\n        field_name: Spanned<FieldName>,\n        type_name: Qualified<CustomTypeName>,\n    },\n    #[error(\n        \"unknown field '{field_name}' for type '{type_name}' used in target mapping for relationship '{relationship_name}'\"\n    )]\n    UnknownFieldInModelRelationshipTargetMapping {\n        field_name: FieldName,\n        type_name: Qualified<CustomTypeName>,\n        relationship_name: RelationshipName,\n    },\n    #[error(\"boolean expression '{boolean_expression_name:}' not found\")]\n    BooleanExpressionNotFound {\n        boolean_expression_name: Qualified<CustomTypeName>,\n    },\n    #[error(\n        \"field '{field_name:}' could not be found in boolean expression type for object type '{type_name:}'\"\n    )]\n    BooleanExpressionFieldNotFound {\n        field_name: Spanned<FieldName>,\n        type_name: Qualified<CustomTypeName>,\n    },","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/types/error.rs#L395-L431","documentation":"While resolving a relationship's target mapping, the resolver found a field name on the target type that does not exist. Relationship target mappings map source fields to target-model fields; any target-side field name that is not defined on the target type triggers this error.","triggerScenarios":"Declaring a relationship with `targetMapping: {field: <targetField>}` where `<targetField>` is not a field of the target model; renaming or removing target-model fields after the relationship was defined.","commonSituations":"Target model evolved (field renamed/removed) but relationship mappings kept the old name; typos in relationship mappings; copy-pasting mappings between models with different fields.","solutions":["Open the relationship named `relationship_name` and check its target mapping entries","Correct each `field` on the target side to a field that exists on `type_name` (the target type)","If the target field was removed, remap to an equivalent existing field or drop the mapping entry","Add metadata validation in CI to catch dangling relationship mappings after model changes"],"exampleFix":"# before\nrelationships:\n  - name: articles\n    targetMapping: {author: authorID}   # authorID not a field of target\n# after\nrelationships:\n  - name: articles\n    targetMapping: {author: author_id}  # actual field name\n","handlingStrategy":"validation","validationCode":"// Validate relationship target mappings against the target type's fields\nfor (src, tgt) in &relationship.target_mapping {\n    if !target_type.fields.contains_key(tgt) {\n        return Err(format!(\"target field {tgt} not on {}\", target_type.name));\n    }\n}","typeGuard":"fn target_field_exists(t: &ObjectType, f: &FieldName) -> bool {\n    t.fields.contains_key(f)\n}","tryCatchPattern":"if let Err(Error::UnknownFieldInModelRelationshipTargetMapping { field_name, type_name, relationship_name }) = result {\n    return Err(format!(\"relationship {relationship_name}: {field_name} missing on {type_name}\"));\n}","preventionTips":["When renaming target-model fields, grep relationship target mappings too","CI-validate all relationship mappings against model schemas"],"tags":["metadata","relationship","field-mapping","hasura"],"backgroundTag":"relationship-mapping-invalid","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}