{"record":{"id":"9f6311a551ca8d4f","repo":"theforeman/foreman","slug":"unable-to-retrieve-unused-ip","errorCode":null,"errorMessage":"Unable to retrieve unused IP","messagePattern":"Unable to retrieve unused IP","errorType":"exception","errorClass":"ProxyAPI::ProxyException","httpStatus":null,"severity":"error","filePath":"app/services/proxy_api/dhcp.rb","lineNumber":38,"sourceCode":"      raise ProxyException.new(url, e, N_(\"Unable to retrieve DHCP subnet\"))\n    end\n\n    def unused_ip(subnet, mac = nil)\n      params = {}\n      params[:mac] = mac if mac.present?\n\n      if subnet.from.present? && subnet.to.present?\n        params[:from] = subnet.from\n        params[:to] = subnet.to\n      end\n      if params.any?\n        params = params.map { |e| e.join(\"=\") }.join(\"&\")\n      else\n        params = \"\"\n      end\n      parse get(\"#{subnet.network}/unused_ip\", query: params)\n    rescue => e\n      raise ProxyException.new(url, e, N_(\"Unable to retrieve unused IP\"))\n    end\n\n    # Retrieves a DHCP entry for a mac\n    # [+subnet+] : String in dotted decimal format\n    # [+mac+]    : String in coloned sextuplet format\n    # Returns    : Hash or false\n    def record(subnet, mac)\n      response = parse(get(\"#{subnet}/mac/#{mac}\"))\n      attrs = response.merge(:network => subnet, :proxy => self)\n      if response.keys.grep(/Sun/i).empty?\n        Net::DHCP::Record.new attrs\n      else\n        Net::DHCP::SparcRecord.new attrs\n      end\n    rescue RestClient::ResourceNotFound\n      nil\n    rescue => e\n      raise ProxyException.new(url, e, N_(\"Unable to retrieve DHCP entry for %s\"), mac)","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/theforeman/foreman/blob/6b05625475cfe6aac31a88f8c8ee6e62e4efe620/app/services/proxy_api/dhcp.rb#L20-L56","documentation":"Error \"Unable to retrieve unused IP\" thrown in theforeman/foreman.","triggerScenarios":"Thrown at app/services/proxy_api/dhcp.rb:38 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"}