{"record":{"id":"d807842ee53f07f4","repo":"hasura/graphql-engine","slug":"error-in-array-item-inner-error","errorCode":null,"errorMessage":"Error in array item: {inner_error:}","messagePattern":"Error in array item: (.+?)","errorType":"validation","errorClass":"TypecheckError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/helpers/typecheck.rs","lineNumber":19,"sourceCode":"//! Functions for typechecking JSON literals against expected types\nuse std::collections::{BTreeMap, BTreeSet};\n\nuse crate::stages::object_types;\nuse crate::types::error::ShouldBeAnError;\nuse crate::{Qualified, QualifiedBaseType, QualifiedTypeName, QualifiedTypeReference};\nuse open_dds::flags::Flag;\nuse open_dds::types::{CustomTypeName, FieldName};\nuse thiserror::Error;\n\n#[derive(Error, Debug, PartialEq)]\n/// Errors that can occur when typechecking a value\npub enum TypecheckError {\n    #[error(\"Expected a value of type {expected:} but got value {actual:}\")]\n    ScalarTypeMismatch {\n        expected: open_dds::types::InbuiltType,\n        actual: serde_json::Value,\n    },\n    #[error(\"Error in array item: {inner_error:}\")]\n    ArrayItemMismatch { inner_error: Box<TypecheckError> },\n    #[error(\"Expected an array but instead got value {value:}\")]\n    NonArrayValue { value: serde_json::Value },\n    #[error(\"Expected a non-null value but received null\")]\n    NullInNonNullableColumn,\n}\n\n#[derive(Error, Debug, PartialEq)]\n/// Issues that can occur when typechecking a value against an object type\npub enum TypecheckIssue {\n    #[error(\"Expected an object value of type {expected:} but got value {actual:}\")]\n    ObjectTypeMismatch {\n        expected: Qualified<CustomTypeName>,\n        actual: serde_json::Value,\n    },\n\n    #[error(\"Typecheck failed for field {field_name:} in object type {object_type:}: {error:}\")]\n    ObjectTypeField {","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/helpers/typecheck.rs#L1-L37","documentation":"A wrapper variant of TypecheckError indicating that an element inside a JSON array literal failed its own typecheck. The inner error is boxed, so the message nests the underlying failure (frequently a ScalarTypeMismatch) and tells you the problem is with an individual item, not the array itself.","triggerScenarios":"Declaring an array-typed argument or field with a default value where at least one element has the wrong JSON type for the element type, e.g. [1, \"two\"] for [Int!].","commonSituations":"Mixed-type arrays in metadata defaults, copy-paste errors in long literal arrays, or changing an element scalar type without updating existing defaults.","solutions":["Fix the specific array element reported by the nested {inner_error:}","Verify every element of the literal array against the declared element type","If heterogeneous values are intended, reconsider the element type definition"],"exampleFix":"// before\ndefault: [1, \"2\", 3]   # element type Int\n\n// after\ndefault: [1, 2, 3]","handlingStrategy":"validation","validationCode":"fn all_items_match(element_check: impl Fn(&serde_json::Value) -> bool, v: &serde_json::Value) -> bool {\n    v.as_array().map(|a| a.iter().all(&element_check)).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"// Unwrap ArrayItemMismatch and report the inner error's position when displaying:\nif let TypecheckError::ArrayItemMismatch { inner_error } = err {\n    report(\"array item failed: {inner_error}\");\n}","preventionTips":["Validate each array element before submitting metadata","Avoid mixed-type literal arrays","Add unit tests for default values of array-typed arguments"],"tags":["metadata","typecheck","array","json"],"backgroundTag":"value-type-mismatch","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}