hasura/graphql-engine · error · StringOperatorReason

scalar type '{scalar_type}' is not a string

Error message

scalar type '{scalar_type}' is not a string

What it means

Nested reason for OnlyApplicableOnStringScalar: the scalar type the boolean expression is defined on is not a string type, so string operators cannot apply.

Source

Thrown at v3/crates/metadata-resolve/src/stages/scalar_boolean_expressions/error.rs:181

    #[error(
        "the operator '{operator_name}' in the boolean expression '{type_name}' is only applicable on string scalars: {reason}"
    )]
    OnlyApplicableOnStringScalar {
        type_name: Qualified<CustomTypeName>,
        operator_name: OperatorName,
        reason: StringOperatorReason,
    },
}

impl ShouldBeAnError for ScalarBooleanExpressionOperatorIssue {
    fn should_be_an_error(&self, flags: &flags::OpenDdFlags) -> bool {
        flags.contains(flags::Flag::ValidateScalarBooleanExpressionOperators)
    }
}

#[derive(Debug, thiserror::Error)]
pub enum StringOperatorReason {
    #[error("scalar type '{scalar_type}' is not a string")]
    ScalarTypeNotString { scalar_type: QualifiedTypeName },
    #[error("argument type '{argument_type}' is not a string")]
    ArgumentTypeNotString { argument_type: QualifiedTypeName },
    #[error("argument type '{argument_type}' is a list")]
    ArgumentTypeShouldNotBeList {
        argument_type: QualifiedTypeReference,
    },
}

#[derive(Debug, Eq, PartialEq, Copy, Clone, derive_more::with_trait::Display)]
#[allow(clippy::enum_variant_names)] // It's fine that they all end with "Operator" :/
pub enum FieldNameSource {
    #[display("comparable operator")]
    ComparisonOperator,
    #[display("logical operator")]
    LogicalOperator,
    #[display("is null operator")]
    IsNullOperator,

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Remove the string operator from this boolean expression type
  2. Define the string operator on a string-based boolean expression type instead
Defensive patterns

Strategy: type-guard

Type guard

fn is_string_scalar(t: &QualifiedTypeName) -> bool {
    matches!(t, QualifiedTypeName::BuiltIn(open_dds::types::BuiltInType::String))
}

Prevention

When it happens

Trigger: A string operator is configured on a boolean expression type whose underlying QualifiedTypeName is not a string scalar.

Common situations: Applying like/ilike operators to numeric, boolean, uuid, or date scalar types.

Related errors


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