hasura/graphql-engine · error · ScalarTypesError

the following type is defined more than once: {name:}

Error message

the following type is defined more than once: {name:}

What it means

Two scalar type definitions in the metadata have the same qualified name (subgraph + CustomTypeName), which is ambiguous.

Source

Thrown at v3/crates/metadata-resolve/src/stages/scalar_types/error.rs:10

use crate::stages::graphql_config;
use crate::types::error::ContextualError;
use crate::types::subgraph::Qualified;
use open_dds::types::CustomTypeName;

#[derive(Debug, thiserror::Error)]
pub enum ScalarTypesError {
    #[error("{0}")]
    GraphqlConfigError(#[from] graphql_config::GraphqlConfigError),
    #[error("the following type is defined more than once: {name:}")]
    DuplicateTypeDefinition { name: Qualified<CustomTypeName> },
}

impl ContextualError for ScalarTypesError {
    fn create_error_context(&self) -> Option<error_context::Context> {
        match self {
            ScalarTypesError::GraphqlConfigError(_)
            | ScalarTypesError::DuplicateTypeDefinition { .. } => None,
        }
    }
}

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Rename one of the duplicate scalar type definitions
  2. Remove the redundant type definition
  3. Split types into distinct subgraphs if the duplication is intentional namespacing

Example fix

// before
# doc1.k8s.yaml and doc2.k8s.yaml both define
kind: ScalarType
name: my_scalar
// after
# rename in doc2
kind: ScalarType
name: my_scalar_v2
Defensive patterns

Strategy: validation

Validate before calling

let mut seen = HashSet::new();
for st in &metadata_accessor.scalar_types {
    if !seen.insert(st.name.clone()) {
        return Err(format!("duplicate scalar type: {}", st.name));
    }
}

Prevention

When it happens

Trigger: Declaring the same custom scalar type name in the same subgraph in two different metadata documents (or twice in one document).

Common situations: Merging metadata files that both define a type, or re-adding a type under a different document without renaming.

Related errors


AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28). Data as JSON: /api/errors/d1b5bfea9c1d9502. Report an issue: GitHub.