hasura/graphql-engine · error · CommandPermissionIssue::CommandArgumentPresetTypecheckIssue

Type error in preset argument {argument_name:} {}in command

Error message

Type error in preset argument {argument_name:} {}in command {command_name:}: {typecheck_issue:}

What it means

CommandArgumentPresetTypecheckIssue is emitted when the value expression preset for a command argument fails typechecking against the argument's declared type. During the command permissions stage, each role-scoped preset is typechecked; a mismatch (wrong scalar type, wrong object shape, bad expression) produces this issue with the underlying typecheck detail.

Source

Thrown at v3/crates/metadata-resolve/src/stages/command_permissions/types.rs:53

    pub arguments: IndexMap<ArgumentName, ArgumentInfo>,
    pub graphql_api: Option<commands::CommandGraphQlApi>,
    pub source: Option<Arc<commands::CommandSource>>,
    #[serde(default = "serde_ext::ser_default")]
    #[serde(skip_serializing_if = "serde_ext::is_ser_default")]
    pub description: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct CommandPermission {
    pub allow_execution: bool,
    pub argument_presets:
        BTreeMap<ArgumentName, (QualifiedTypeReference, ValueExpressionOrPredicate)>,
}

#[derive(Debug, thiserror::Error)]
#[allow(clippy::enum_variant_names)]
pub enum CommandPermissionIssue {
    #[error(
        "Type error in preset argument {argument_name:} {}in command {command_name:}: {typecheck_issue:}", 
            {match role { Some(role) => format!("for role {role} "), None => String::new()}}) 
    ]
    CommandArgumentPresetTypecheckIssue {
        role: Option<Role>,
        command_name: Qualified<CommandName>,
        argument_name: ArgumentName,
        typecheck_issue: typecheck::TypecheckIssue,
    },
    #[error(
        "the object type {data_type} used as a return type for command {command_name} uses rules-based authorization so will not appear in the GraphQL schema"
    )]
    CommandReturnTypeUsesRulesBasedAuthorization {
        command_name: Qualified<CommandName>,
        data_type: Qualified<CustomTypeName>,
    },
    #[error(
        "the command {command_name} uses rules-based authorization so will not appear in the GraphQL schema"

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Check the underlying typecheck_issue message and fix the preset value to match the argument's declared type
  2. Update presets after changing an argument's type so value kinds align
  3. If using a variable/expression in the preset, ensure it resolves to the argument's type (e.g. session variable used for a UUID argument is actually a UUID)
  4. For predicate presets, confirm the argument is a boolean expression input type before using _eq/_comparators

Example fix

# before
command_permissions:
  select:
    presets:
      tenant_id: "hardcoded-string"   # argument is UUID!

# after
command_permissions:
  select:
    presets:
      tenant_id: $session.x_tenant_id  # session variable holding a UUID
Defensive patterns

Strategy: validation

Validate before calling

// Typecheck presets against argument types before submission
for (arg_name, (arg_ty, preset)) in &command.select.presets {
    if let Err(e) = typecheck_value_expression(preset, arg_ty) {
        return Err(format!("preset for {arg_name} fails typecheck: {e}"));
    }
}

Try / catch

Catch CommandArgumentPresetTypecheckIssue and surface command_name, argument_name, role, and the embedded typecheck_issue so users know exactly which preset to fix.

Prevention

When it happens

Trigger: Setting command_permissions select presets where a preset value's ValueExpressionOrPredicate does not typecheck against the QualifiedTypeReference of the argument, e.g. presetting a string literal to an Int argument or a predicate on a non-predicate argument.

Common situations: Setting role-based presets with literal values whose JSON type doesn't match the argument type; changing an argument's type (Int -> Float, ID -> UUID) without updating presets; presetting comparison expressions on arguments that are not predicate-typed; role-conditional presets drifting out of sync after schema changes.

Related errors


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