imathis/octopress · error · ArgumentError
GitHub replied with a 302 but didn't provide a location in t
Error message
GitHub replied with a 302 but didn't provide a location in the response headers.
What it means
ArgumentError raised in handle_gist_redirecting (gist_tag.rb:96-100) when a response arrives with code 301/302 but the Location header is nil or empty. Something announced a redirect yet gave no destination, so the plugin cannot follow it. Genuine GitHub responses always carry a Location header, so this almost always implicates an intermediary: the ENV['http_proxy'] proxy wired in by get_web_content, a captive portal, or an SSL-inspecting middlebox — the plugin sets verify_mode = OpenSSL::SSL::VERIFY_NONE (line 115), so interception is accepted silently. It propagates out of the Liquid tag and aborts the Jekyll build.
Source
Thrown at plugins/gist_tag.rb:99
locations = Array.new
while (data.code.to_i == 301 || data.code.to_i == 302)
data = handle_gist_redirecting(data)
break if locations.include? data.header['Location']
locations << data.header['Location']
end
if data.code.to_i != 200
raise RuntimeError, "Gist replied with #{data.code} for #{gist_url}"
end
cache(gist, file, data.body) unless @cache_disabled
data.body
end
def handle_gist_redirecting(data)
redirected_url = data.header['Location']
if redirected_url.nil? || redirected_url.empty?
raise ArgumentError, "GitHub replied with a 302 but didn't provide a location in the response headers."
end
get_web_content(redirected_url)
end
def get_web_content(url)
raw_uri = URI.parse url
proxy = ENV['http_proxy']
if proxy
proxy_uri = URI.parse(proxy)
https = Net::HTTP::Proxy(proxy_uri.host, proxy_uri.port).new raw_uri.host, raw_uri.port
else
https = Net::HTTP.new raw_uri.host, raw_uri.port
end
https.use_ssl = true
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new raw_uri.request_uri
data = https.request requestView on GitHub (pinned to 5717a50f4e)
Solutions
- Unset or fix the proxy before building: env -u http_proxy -u https_proxy jekyll build (also check CI environment variable settings)
- Confirm direct reachability: curl -sI https://gist.githubusercontent.com/raw/<id>/<file> should show 301/302 WITH a Location line
- Commit a populated .gist-cache so builds take the cached path and never follow redirects
- Patch the redirect loop to skip Location-less redirects (see exampleFix) or switch to an HTTP client that follows redirects safely
Example fix
# before (plugins/gist_tag.rb:82-86) while (data.code.to_i == 301 || data.code.to_i == 302) data = handle_gist_redirecting(data) break if locations.include? data.header['Location'] locations << data.header['Location'] end # after - a 302 with no Location is treated as a normal non-200 response while (data.code.to_i == 301 || data.code.to_i == 302) && !data.header['Location'].to_s.empty? data = handle_gist_redirecting(data) break if locations.include? data.header['Location'] locations << data.header['Location'] end
Defensive patterns
Strategy: validation
Validate before calling
# Check a redirect actually goes somewhere before following it def followable_redirect?(response) return false unless [301, 302].include?(response.code.to_i) loc = response.header['Location'].to_s return false if loc.strip.empty? uri = URI.parse(loc) rescue nil !uri.nil? end
Try / catch
begin
data = get_web_content(gist_url)
rescue ArgumentError => e
raise unless e.message.include?("didn't provide a location")
warn "Redirect without Location (proxy interference?) for #{gist_url}"
next # or return "<!-- gist #{gist} skipped: malformed redirect -->"
end Prevention
- Unset or correct http_proxy/https_proxy in CI before running jekyll build
- Verify with curl -sI that 302 responses from gist.githubusercontent.com include a Location header
- Commit .gist-cache so builds never follow redirects
- Patch get_web_content to use OpenSSL::SSL::VERIFY_PEER so MITM proxies fail loudly instead of silently issuing bogus redirects
When it happens
Trigger: ENV['http_proxy'] pointing at a proxy that answers 302 without a Location header; a captive portal or transparent proxy intercepting the HTTPS request to gist.githubusercontent.com; any garbled or truncated response where data.header['Location'] resolves to nil. Only reachable when the first or a chained response's code is 301/302.
Common situations: CI runners exporting a generic http_proxy; corporate networks with SSL-inspecting appliances; building the site on hotel/airport wifi behind a captive portal; rare load-balancer misconfigurations during a GitHub incident.
Related errors
- Gist replied with #{data.code} for #{gist_url}
- Error in tag 'include_array' - Valid syntax: include_array [
AI-assisted analysis of imathis/octopress@5717a50f4e (2026-08-21).
Data as JSON: /api/errors/a2786388196fc43c.
Report an issue: GitHub.