{"record":{"id":"5481f27a130c146d","repo":"hasura/graphql-engine","slug":"type-error-in-preset-argument-argument-name-i","errorCode":null,"errorMessage":"Type error in preset argument {argument_name:} {}in command {command_name:}: {typecheck_issue:}","messagePattern":"Type error in preset argument (.+?) (.+?)in command (.+?): (.+?)","errorType":"validation","errorClass":"CommandPermissionIssue::CommandArgumentPresetTypecheckIssue","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/stages/command_permissions/types.rs","lineNumber":53,"sourceCode":"    pub arguments: IndexMap<ArgumentName, ArgumentInfo>,\n    pub graphql_api: Option<commands::CommandGraphQlApi>,\n    pub source: Option<Arc<commands::CommandSource>>,\n    #[serde(default = \"serde_ext::ser_default\")]\n    #[serde(skip_serializing_if = \"serde_ext::is_ser_default\")]\n    pub description: Option<String>,\n}\n\n#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]\npub struct CommandPermission {\n    pub allow_execution: bool,\n    pub argument_presets:\n        BTreeMap<ArgumentName, (QualifiedTypeReference, ValueExpressionOrPredicate)>,\n}\n\n#[derive(Debug, thiserror::Error)]\n#[allow(clippy::enum_variant_names)]\npub enum CommandPermissionIssue {\n    #[error(\n        \"Type error in preset argument {argument_name:} {}in command {command_name:}: {typecheck_issue:}\", \n            {match role { Some(role) => format!(\"for role {role} \"), None => String::new()}}) \n    ]\n    CommandArgumentPresetTypecheckIssue {\n        role: Option<Role>,\n        command_name: Qualified<CommandName>,\n        argument_name: ArgumentName,\n        typecheck_issue: typecheck::TypecheckIssue,\n    },\n    #[error(\n        \"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\"\n    )]\n    CommandReturnTypeUsesRulesBasedAuthorization {\n        command_name: Qualified<CommandName>,\n        data_type: Qualified<CustomTypeName>,\n    },\n    #[error(\n        \"the command {command_name} uses rules-based authorization so will not appear in the GraphQL schema\"","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/stages/command_permissions/types.rs#L35-L71","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the underlying typecheck_issue message and fix the preset value to match the argument's declared type","Update presets after changing an argument's type so value kinds align","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)","For predicate presets, confirm the argument is a boolean expression input type before using _eq/_comparators"],"exampleFix":"# before\ncommand_permissions:\n  select:\n    presets:\n      tenant_id: \"hardcoded-string\"   # argument is UUID!\n\n# after\ncommand_permissions:\n  select:\n    presets:\n      tenant_id: $session.x_tenant_id  # session variable holding a UUID","handlingStrategy":"validation","validationCode":"// Typecheck presets against argument types before submission\nfor (arg_name, (arg_ty, preset)) in &command.select.presets {\n    if let Err(e) = typecheck_value_expression(preset, arg_ty) {\n        return Err(format!(\"preset for {arg_name} fails typecheck: {e}\"));\n    }\n}","typeGuard":null,"tryCatchPattern":"Catch CommandArgumentPresetTypecheckIssue and surface command_name, argument_name, role, and the embedded typecheck_issue so users know exactly which preset to fix.","preventionTips":["Keep presets type-consistent with argument declarations; update both together in one change","Add CI checks that typecheck presets after any argument type change","Prefer session variables over hardcoded literals for typed arguments"],"tags":["hasura","commands","typecheck","presets","permissions"],"backgroundTag":"argument-type-mismatch","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}