{"record":{"id":"22d06942f1f1677f","repo":"CanineHQ/canine","slug":"unauthorized-to-access-portainer","errorCode":null,"errorMessage":"Unauthorized to access Portainer","messagePattern":"Unauthorized to access Portainer","errorType":"exception","errorClass":"Portainer::Client::UnauthorizedError","httpStatus":401,"severity":"error","filePath":"lib/portainer/client.rb","lineNumber":170,"sourceCode":"\n  private\n\n    def headers\n      @headers ||= {\n        'Content-Type' => 'application/json'\n      }.tap do |headers|\n        if jwt.is_a?(UserJWT)\n          headers['Authorization'] = \"Bearer #{jwt.token}\"\n        else\n          headers['X-API-Key'] = jwt.token\n        end\n      end\n    end\n\n    def fetch_wrapper(&block)\n      response = yield\n\n      raise UnauthorizedError, \"Unauthorized to access Portainer\" if response.code == 401\n      raise PermissionDeniedError, \"Permission denied to access Portainer\" if response.code == 403\n\n      if response.success?\n        response.parsed_response\n      else\n        raise \"Failed to fetch from Portainer: #{response.code} #{response.body}\"\n      end\n    end\n  end\nend\n","sourceCodeStart":152,"sourceCodeEnd":181,"githubUrl":"https://github.com/CanineHQ/canine/blob/ba4ee3968d8513ee27d8583fbd3e854a8dd053f3/lib/portainer/client.rb#L152-L181","documentation":"Error \"Unauthorized to access Portainer\" thrown in CanineHQ/canine.","triggerScenarios":"Thrown at lib/portainer/client.rb:170 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":"ba4ee3968d8513ee27d8583fbd3e854a8dd053f3","analyzedAt":"2026-08-23T17:49:27.834Z","schemaVersion":2},"datasetVersion":"2026-08-23T21:17:23.414Z"}