{"record":{"id":"4e8c828ba1089a90","repo":"hasura/graphql-engine","slug":"the-source-field-source-field-name-of-type-s","errorCode":null,"errorMessage":"The source field '{source_field_name}' of type '{source_field_type}' in the relationship '{relationship_name}' on type '{source_type}' cannot be mapped to the target argument '{target_argument_name}' of type '{target_argument_type}' on the target model '{target_model_name}' because their types are incompatible","messagePattern":"The source field '(.+?)' of type '(.+?)' in the relationship '(.+?)' on type '(.+?)' cannot be mapped to the target argument '(.+?)' of type '(.+?)' on the target model '(.+?)' because their types are incompatible","errorType":"validation","errorClass":"RelationshipError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/stages/object_relationships/error.rs","lineNumber":143,"sourceCode":"        data_connector_name: Qualified<DataConnectorName>,\n    },\n    #[error(\n        \"The relationship {relationship_name} on type {type_name} defines an aggregate, but aggregates can only be used with array relationships, not object relationships\"\n    )]\n    AggregateIsOnlyAllowedOnArrayRelationships {\n        type_name: Qualified<CustomTypeName>,\n        relationship_name: RelationshipName,\n    },\n    #[error(\n        \"The aggregate defined on the relationship {relationship_name} on type {type_name} has an error: {error}\"\n    )]\n    ModelAggregateExpressionError {\n        type_name: Qualified<CustomTypeName>,\n        relationship_name: RelationshipName,\n        error: models::ModelsError, // ideally, this would return the more accurate\n                                    // `ModelAggregateExpressionError` instead\n    },\n    #[error(\n        \"The source field '{source_field_name}' of type '{source_field_type}' in the relationship '{relationship_name}' on type '{source_type}' cannot be mapped to the target argument '{target_argument_name}' of type '{target_argument_type}' on the target model '{target_model_name}' because their types are incompatible\"\n    )]\n    ModelArgumentTargetMappingTypeMismatch {\n        source_type: Qualified<CustomTypeName>,\n        relationship_name: RelationshipName,\n        source_field_name: FieldName,\n        source_field_type: QualifiedTypeReference,\n        target_model_name: Qualified<ModelName>,\n        target_argument_name: ArgumentName,\n        target_argument_type: QualifiedTypeReference,\n    },\n    #[error(\"Relationship mappings from value expressions are not supported yet.\")]\n    ValueExpressionMappingsNotSupportedYet,\n    #[error(\n        \"The field path provided in the {location:} of the relationship {relationship_name} on type {type_name} is empty\"\n    )]\n    EmptyFieldPath {\n        location: String,","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/object_relationships/error.rs#L125-L161","documentation":"A relationship argument mapping tried to map a source field to a target model argument whose types are incompatible (e.g. mapping a String field to an Int argument). The resolver compares the source field's QualifiedTypeReference with the target argument's type and rejects mismatches.","triggerScenarios":"Mapping `author_id: String` on the source type to a model argument `author_id: Int` (or any non-castable combination, including object vs scalar mismatches).","commonSituations":"Underlying database schema changes that alter column types; generating types in a different order so IDs become UUID vs Int; metadata authored by hand without type checking.","solutions":["Compare the source field type and target argument type shown in the message and make them compatible","Change the source field's type or pick a different source field whose type matches","Alter the target model argument type, or add a compatible intermediate field/cast in the source schema"],"exampleFix":"// before\n// source field: author_id: String\nargument_mappings:\n  author_id: author_id   # model argument author_id: Int\n// after\n// change source field type to match:\nauthor_id: Int","handlingStrategy":"type-guard","validationCode":"const srcT = types[srcType].fields[m.source]?.type;\nconst argT = models[targetModel].arguments.find(a => a.name === m.target.argument)?.type;\nif (srcT && argT && !typesCompatible(srcT, argT)) throw new Error(`type mismatch: ${srcT} vs ${argT}`);","typeGuard":"function typesCompatible(a: string, b: string): boolean {\n  const norm = (t: string) => t.replace(/^(Int|Float|Numeric|String|Boolean|ID|Uuid|Date|Timestamp).*$/, m => m);\n  return norm(a) === norm(b) || (a === 'Int' && b === 'Float') || (a === 'Float' && b === 'Numeric');\n}","tryCatchPattern":"try { await applyMetadata(md); } catch (e) { if (/types are incompatible/.test(e.message)) { /* align the two named types */ } throw e; }","preventionTips":["Keep ID column types consistent across schemas (all Int or all UUID)","Validate mapping types with a script that reads both type and model definitions"],"tags":["metadata","relationships","type-mismatch","argument-mapping"],"backgroundTag":"type-mismatch-in-mapping","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}