{"record":{"id":"42412f2d0bfbb1b7","repo":"theforeman/foreman","slug":"unable-to-get-environment-from-puppet","errorCode":null,"errorMessage":"Unable to get environment from Puppet","messagePattern":"Unable to get environment from Puppet","errorType":"exception","errorClass":"ProxyException","httpStatus":null,"severity":"error","filePath":"app/services/proxy_api/puppet.rb","lineNumber":17,"sourceCode":"module ProxyAPI\n  class Puppet < ProxyAPI::Resource\n    def initialize(args)\n      @url = args[:url] + \"/puppet\"\n      super args\n    end\n\n    def environments\n      parse(get(\"environments\"))\n    rescue => e\n      raise ProxyException.new(url, e, N_(\"Unable to get environments from Puppet\"))\n    end\n\n    def environment(env)\n      parse(get(\"environments/#{env}\"))\n    rescue => e\n      raise ProxyException.new(url, e, N_(\"Unable to get environment from Puppet\"))\n    end\n\n    def classes(env)\n      return if env.blank?\n      pcs = parse(get(\"environments/#{env}/classes\"))\n      Hash[pcs.map { |k| [k.keys.first, Foreman::ImporterPuppetclass.new(k.values.first)] }]\n    rescue RestClient::ResourceNotFound\n      {}\n    rescue => e\n      raise ProxyException.new(url, e, N_(\"Unable to get classes from Puppet for %s\"), env)\n    end\n\n    def class_count(env)\n      return if env.blank?\n      pcs = parse(get(\"environments/#{env}/classes\"))\n      pcs.length\n    rescue => e\n      raise ProxyException.new(url, e, N_(\"Unable to get classes from Puppet for %s\"), env)","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/theforeman/foreman/blob/6b05625475cfe6aac31a88f8c8ee6e62e4efe620/app/services/proxy_api/puppet.rb#L1-L35","documentation":"Error \"Unable to get environment from Puppet\" thrown in theforeman/foreman.","triggerScenarios":"Thrown at app/services/proxy_api/puppet.rb:17 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"}