hasura/graphql-engine · error · ModelPermissionError

preset argument '{argument_name}' is defined more than once

Error message

preset argument '{argument_name}' is defined more than once

What it means

DuplicateModelArgumentPreset: a model permission defines a preset for the same argument name more than once within the same role's permission block. Argument presets must be unique per role; resolution stops at the duplicate (the span of the second occurrence is reported).

Source

Thrown at v3/crates/metadata-resolve/src/stages/model_permissions/error.rs:25

use open_dds::data_connector::DataConnectorName;
use open_dds::{
    models::ModelName, permissions::Role, query::ArgumentName, spanned::Spanned,
    types::CustomTypeName,
};

#[derive(Debug, thiserror::Error)]
#[error("Error in model permission for model '{model_name}'{}: {error}",
        match role { Some(role) => format!(" for role '{role}'"), None => String::new()}
)]
pub struct NamedModelPermissionError {
    pub model_name: Qualified<ModelName>,
    pub role: Option<Spanned<Role>>,
    pub error: ModelPermissionError,
}

#[derive(Debug, thiserror::Error)]
pub enum ModelPermissionError {
    #[error("preset argument '{argument_name}' is defined more than once")]
    DuplicateModelArgumentPreset {
        argument_name: Spanned<ArgumentName>,
    },

    #[error("model source is required for model '{model_name:}' to resolve predicate")]
    ModelSourceRequiredForPredicate {
        model_name: Spanned<Qualified<ModelName>>,
    },

    #[error("preset argument '{argument_name}' value has a type error: {type_error}")]
    ModelArgumentValuePresetTypeError {
        argument_name: Spanned<ArgumentName>,
        value_path: JSONPath,
        type_error: typecheck::TypecheckError,
    },

    #[error(
        "a preset argument '{argument_name}' has been set for the model '{model_name}' but no such argument exists for this model"

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Open the model permission for the reported role and remove the duplicate argument preset entry
  2. If different sources add presets, keep exactly one per argument name per role
  3. Validate presets with `ddn build` or metadata lint before deploy

Example fix

# before
permissions:
  - role: user
    select:
      argumentPresets:
        - argument: id
          value: 1
        - argument: id
          value: 2

# after
permissions:
  - role: user
    select:
      argumentPresets:
        - argument: id
          value: 1
Defensive patterns

Strategy: validation

Validate before calling

for perm in model['permissions']:
    for role_perm in perm.values():
        presets = role_perm.get('argumentPresets', [])
        names = [p['argument'] for p in presets]
        assert len(names) == len(set(names)), f'duplicate presets: {names}'

Prevention

When it happens

Trigger: Declaring the same argument name twice under `argumentPresets` in one role's model permission in OpenDD metadata, e.g. two `id:` entries after a YAML copy-paste or list merge.

Common situations: Copy-pasting preset entries, YAML anchors merging lists unexpectedly, adding a preset without checking existing ones for the same role.

Related errors


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