hasura/graphql-engine · error · TypecheckError
Error in array item: {inner_error:}
Error message
Error in array item: {inner_error:} What it means
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.
Source
Thrown at v3/crates/metadata-resolve/src/helpers/typecheck.rs:19
//! Functions for typechecking JSON literals against expected types
use std::collections::{BTreeMap, BTreeSet};
use crate::stages::object_types;
use crate::types::error::ShouldBeAnError;
use crate::{Qualified, QualifiedBaseType, QualifiedTypeName, QualifiedTypeReference};
use open_dds::flags::Flag;
use open_dds::types::{CustomTypeName, FieldName};
use thiserror::Error;
#[derive(Error, Debug, PartialEq)]
/// Errors that can occur when typechecking a value
pub enum TypecheckError {
#[error("Expected a value of type {expected:} but got value {actual:}")]
ScalarTypeMismatch {
expected: open_dds::types::InbuiltType,
actual: serde_json::Value,
},
#[error("Error in array item: {inner_error:}")]
ArrayItemMismatch { inner_error: Box<TypecheckError> },
#[error("Expected an array but instead got value {value:}")]
NonArrayValue { value: serde_json::Value },
#[error("Expected a non-null value but received null")]
NullInNonNullableColumn,
}
#[derive(Error, Debug, PartialEq)]
/// Issues that can occur when typechecking a value against an object type
pub enum TypecheckIssue {
#[error("Expected an object value of type {expected:} but got value {actual:}")]
ObjectTypeMismatch {
expected: Qualified<CustomTypeName>,
actual: serde_json::Value,
},
#[error("Typecheck failed for field {field_name:} in object type {object_type:}: {error:}")]
ObjectTypeField {View on GitHub (pinned to 724551b9ae)
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
Example fix
// before default: [1, "2", 3] # element type Int // after default: [1, 2, 3]
Defensive patterns
Strategy: validation
Validate before calling
fn all_items_match(element_check: impl Fn(&serde_json::Value) -> bool, v: &serde_json::Value) -> bool {
v.as_array().map(|a| a.iter().all(&element_check)).unwrap_or(false)
} Try / catch
// Unwrap ArrayItemMismatch and report the inner error's position when displaying:
if let TypecheckError::ArrayItemMismatch { inner_error } = err {
report("array item failed: {inner_error}");
} Prevention
- Validate each array element before submitting metadata
- Avoid mixed-type literal arrays
- Add unit tests for default values of array-typed arguments
When it happens
Trigger: 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!].
Common situations: Mixed-type arrays in metadata defaults, copy-paste errors in long literal arrays, or changing an element scalar type without updating existing defaults.
Related errors
- Expected an array but instead got value {value:}
- Expected a value of type {expected:} but got value {actual:}
- Expected an object value of type {expected:} but got value {
- parsing metadata as json: %w
- reading metadata file: %w
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/d807842ee53f07f4.
Report an issue: GitHub.