theforeman/foreman · error · GraphQL::ExecutionError

Resource mismatch, expected #{resource_class.name}, got #{re

Error message

Resource mismatch, expected #{resource_class.name}, got #{resource.class.name}

What it means

Error "Resource mismatch, expected #{resource_class.name}, got #{resource.class.name}" thrown in theforeman/foreman.

Source

Thrown at app/graphql/mutations/base_mutation.rb:46

    delegate :resource_class, to: :class

    def authorize!(resource, action)
      user = context[:current_user]
      authorizer = Authorizer.new(user)
      permission_name = resource.permission_name(action)

      return if action == :create && authorizer.can?(permission_name)
      return if action != :create && authorizer.can?(permission_name, resource)

      raise GraphQL::ExecutionError.new(
        _('Unauthorized. You do not have the required permission %s.') % permission_name
      )
    end

    def validate_object(resource)
      unless resource.is_a?(resource_class)
        raise GraphQL::ExecutionError.new("Resource mismatch, expected #{resource_class.name}, got #{resource.class.name}")
      end
    end

    def load_object_by(id:)
      object = GraphQL::Batch.batch { ForemanGraphqlSchema.object_from_id(id, context) }

      raise GraphQL::ExecutionError.new(_('Could not resolve ID.')) unless object

      validate_object(object)

      object
    end

    def save_object(resource)
      User.as(context[:current_user]) do
        errors = if resource.save
                   []
                 else

View on GitHub (pinned to 6b05625475)

When it happens

Trigger: Thrown at app/graphql/mutations/base_mutation.rb:46 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of theforeman/foreman@6b05625475 (2026-08-23). Data as JSON: /api/errors/2a2faf3d44de3164. Report an issue: GitHub.