{"record":{"id":"2a2faf3d44de3164","repo":"theforeman/foreman","slug":"resource-mismatch-expected-resource-class-name","errorCode":null,"errorMessage":"Resource mismatch, expected #{resource_class.name}, got #{resource.class.name}","messagePattern":"Resource mismatch, expected #(.+?), got #(.+?)","errorType":"validation","errorClass":"GraphQL::ExecutionError","httpStatus":null,"severity":"error","filePath":"app/graphql/mutations/base_mutation.rb","lineNumber":46,"sourceCode":"\n    delegate :resource_class, to: :class\n\n    def authorize!(resource, action)\n      user = context[:current_user]\n      authorizer = Authorizer.new(user)\n      permission_name = resource.permission_name(action)\n\n      return if action == :create && authorizer.can?(permission_name)\n      return if action != :create && authorizer.can?(permission_name, resource)\n\n      raise GraphQL::ExecutionError.new(\n        _('Unauthorized. You do not have the required permission %s.') % permission_name\n      )\n    end\n\n    def validate_object(resource)\n      unless resource.is_a?(resource_class)\n        raise GraphQL::ExecutionError.new(\"Resource mismatch, expected #{resource_class.name}, got #{resource.class.name}\")\n      end\n    end\n\n    def load_object_by(id:)\n      object = GraphQL::Batch.batch { ForemanGraphqlSchema.object_from_id(id, context) }\n\n      raise GraphQL::ExecutionError.new(_('Could not resolve ID.')) unless object\n\n      validate_object(object)\n\n      object\n    end\n\n    def save_object(resource)\n      User.as(context[:current_user]) do\n        errors = if resource.save\n                   []\n                 else","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/theforeman/foreman/blob/6b05625475cfe6aac31a88f8c8ee6e62e4efe620/app/graphql/mutations/base_mutation.rb#L28-L64","documentation":"Error \"Resource mismatch, expected #{resource_class.name}, got #{resource.class.name}\" thrown in theforeman/foreman.","triggerScenarios":"Thrown at app/graphql/mutations/base_mutation.rb:46 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6b05625475cfe6aac31a88f8c8ee6e62e4efe620","analyzedAt":"2026-08-23T17:46:34.094Z","schemaVersion":2},"datasetVersion":"2026-08-23T21:17:23.414Z"}