{"record":{"id":"8af22177ced177ce","repo":"hasura/graphql-engine","slug":"field-field-name-for-type-type-name-referenced","errorCode":null,"errorMessage":"Field {field_name} for type {type_name} referenced in model {model_name} is not defined","messagePattern":"Field (.+?) for type (.+?) referenced in model (.+?) is not defined","errorType":"validation","errorClass":"NDCValidationError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/helpers/ndc_validation.rs","lineNumber":107,"sourceCode":"    )]\n    TypeCapabilityNotDefined {\n        model_name: ModelName,\n        field_name: FieldName,\n        r#type: String,\n    },\n    #[error(\"type {0} is not defined in the agent schema\")]\n    NoSuchType(String),\n    #[error(\"mapping for type {type_name} of model {model_name} is not defined\")]\n    UnknownModelTypeMapping {\n        model_name: Qualified<ModelName>,\n        type_name: Qualified<CustomTypeName>,\n    },\n    #[error(\"mapping for type {type_name} of command {command_name} is not defined\")]\n    UnknownCommandTypeMapping {\n        command_name: Qualified<CommandName>,\n        type_name: Qualified<CustomTypeName>,\n    },\n    #[error(\n        \"Field {field_name} for type {type_name} referenced in model {model_name} is not defined\"\n    )]\n    UnknownTypeField {\n        model_name: ModelName,\n        type_name: CustomTypeName,\n        field_name: FieldName,\n    },\n    #[error(\n        \"Result type of function/procedure {function_or_procedure_name:} is {function_or_procedure_output_type:} but output type of command {command_name:} is {command_output_type:}\"\n    )]\n    FuncProcAndCommandScalarOutputTypeMismatch {\n        function_or_procedure_name: String,\n        function_or_procedure_output_type: String,\n        command_name: String,\n        command_output_type: String,\n    },\n    #[error(\n        \"Custom result type of function {function_or_procedure_name:} does not match custom output type of command: {command_name:}\"","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/helpers/ndc_validation.rs#L89-L125","documentation":"A model references a field of a custom object type that the type definition itself does not declare. Validation ensures each field referenced through a mapped type exists in that type's field set.","triggerScenarios":"Mapping a model field to type T.fieldX where T's ObjectType definition has no fieldX; adding a field to a model's type mapping without declaring it on the ObjectType.","commonSituations":"Renaming a field on an ObjectType but not in model mappings; adding mapped fields before declaring them; divergent copies of type definitions.","solutions":["Declare the missing field on the ObjectType definition for that type","Correct the field name in the model's mapping to match a declared field","Regenerate/refresh metadata if types are generated from another source"],"exampleFix":"# before\n# model maps field 'surname' but ObjectType User only has 'lastName'\n# after\n# rename mapping to 'lastName' or add field 'surname' to ObjectType User","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"fn field_on_type(field: &FieldName, t: &ObjectTypeDefinition) -> bool { t.fields.contains(field) }","tryCatchPattern":null,"preventionTips":["Keep field names in mappings synced with ObjectType definitions; codegen when possible"],"tags":["field-not-defined","object-type","model"],"backgroundTag":"undefined-field-reference","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}