puppetlabs/puppet · error · Puppet::HTTP::ProtocolError
Location response header is missing
Error message
Location response header is missing
What it means
After a 301/302/307, Puppet::HTTP::Redirector#parse_location reads the Location response header to build the next request. RFC-compliant redirects must include it; when the header is absent the redirect cannot continue and Puppet::HTTP::ProtocolError is raised.
Source
Thrown at lib/puppet/http/redirector.rb:81
new_request[header] = value
end
# mimic private Net::HTTP#addr_port
new_request['Host'] = if (location.scheme == 'https' && location.port == 443) ||
(location.scheme == 'http' && location.port == 80)
location.host
else
"#{location.host}:#{location.port}"
end
new_request
end
private
def parse_location(response)
location = response['location']
raise Puppet::HTTP::ProtocolError, _("Location response header is missing") unless location
URI.parse(location)
rescue URI::InvalidURIError => e
raise Puppet::HTTP::ProtocolError.new(_("Location URI is invalid: %{detail}") % { detail: e.message }, e)
end
end
View on GitHub (pinned to e227c27540)
Solutions
- Inspect the raw response (curl -i) and fix the server/proxy to send 'Location: <absolute-or-relative-url>'.
- If the endpoint should not redirect at all, correct the route returning the 3xx.
- Point the client at the final URL so no redirect is involved.
Example fix
# nginx - before
location /puppet {
return 302;
}
# after
location /puppet {
return 302 https://puppet.internal:8140/puppet;
} Defensive patterns
Strategy: try-catch
Try / catch
begin
client.get(uri)
rescue Puppet::HTTP::ProtocolError => e
raise unless e.message.include?('Location response header is missing')
# inspect the 3xx manually and decide: follow the real URL or fail loudly
raise
end Prevention
- Proxy/server rules for redirects must always emit a Location header.
- Smoke-test endpoints with curl -i to catch malformed 3xx responses early.
When it happens
Trigger: A server or intermediary returns 301/302/307 without a Location header (redirect_to is only called for those codes); auth portals or proxies emitting status 302 with an HTML body but no header; header stripped by a middlebox.
Common situations: Custom endpoints or misconfigured nginx/haproxy rules using 'return 302' without a URL; application servers that signal redirects via body meta-refresh; security appliances rewriting responses.
Related errors
- Failed to parse Retry-After header '%{retry_after}' as an in
- 'put' requires a 'content-type' header
- 'post' requires a 'content-type' header
- Too many HTTP redirections for %{addr}
- No content type in http response; cannot parse
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/63f5e33c2e9f43a1.
Report an issue: GitHub.