{"record":{"id":"8d3abe79a3b6919a","repo":"hasura/graphql-engine","slug":"expected-an-array-but-instead-got-value-value","errorCode":null,"errorMessage":"Expected an array but instead got value {value:}","messagePattern":"Expected an array but instead got value (.+?)","errorType":"validation","errorClass":"TypecheckError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/helpers/typecheck.rs","lineNumber":21,"sourceCode":"\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 {\n        field_name: FieldName,\n        object_type: Qualified<CustomTypeName>,","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/helpers/typecheck.rs#L3-L39","documentation":"TypecheckError variant thrown when typechecking an array-typed value but the provided JSON value is not a JSON array (e.g. it is an object, string, or number). It includes the offending value so you can immediately see what was passed instead.","triggerScenarios":"Supplying a scalar or object where the declared type is an array, e.g. default: 5 for an argument typed [Int!]!, or passing an object literal for a list input in metadata.","commonSituations":"Forgetting brackets around single-element defaults, YAML flow-style mistakes that parse as a map instead of a list, mismatched metadata after a schema change from scalar to list.","solutions":["Wrap the value in an array: [value]","Check YAML flow syntax so the value parses as a sequence (starts with '-')","Confirm the declared type really is an array type and not a scalar"],"exampleFix":"// before\ndefault: 5   # type: [Int!]\n\n// after\ndefault: [5]","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"fn is_json_array(v: &serde_json::Value) -> bool {\n    v.is_array()\n}","tryCatchPattern":"if let TypecheckError::NonArrayValue { value } = err {\n    eprintln!(\"expected an array, got {value}; wrap it in []\");\n}","preventionTips":["Always bracket array defaults, even single-element ones","Use YAML block sequences (- item) for list defaults","Double-check types after changing scalars to lists"],"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"}