{"record":{"id":"d2874d7511027253","repo":"imathis/octopress","slug":"gist-replied-with-data-code-for-gist-url","errorCode":null,"errorMessage":"Gist replied with #{data.code} for #{gist_url}","messagePattern":"Gist replied with #(.+?) for #(.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"plugins/gist_tag.rb","lineNumber":89,"sourceCode":"      gist      = gist.gsub bad_chars, ''\n      file      = file.gsub bad_chars, ''\n      md5       = Digest::MD5.hexdigest \"#{gist}-#{file}\"\n      File.join @cache_folder, \"#{gist}-#{file}-#{md5}.cache\"\n    end\n\n    def get_gist_from_web(gist, file)\n      gist_url = get_gist_url_for(gist, file)\n      data     = get_web_content(gist_url)\n\n      locations = Array.new\n      while (data.code.to_i == 301 || data.code.to_i == 302)\n        data = handle_gist_redirecting(data)\n        break if locations.include? data.header['Location']\n        locations << data.header['Location']\n      end\n\n      if data.code.to_i != 200\n        raise RuntimeError, \"Gist replied with #{data.code} for #{gist_url}\"\n      end\n\n      cache(gist, file, data.body) unless @cache_disabled\n      data.body\n    end\n\n    def handle_gist_redirecting(data)\n      redirected_url = data.header['Location']\n      if redirected_url.nil? || redirected_url.empty?\n        raise ArgumentError, \"GitHub replied with a 302 but didn't provide a location in the response headers.\"\n      end\n\n      get_web_content(redirected_url)\n    end\n\n    def get_web_content(url)\n      raw_uri           = URI.parse url\n      proxy             = ENV['http_proxy']","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/imathis/octopress/blob/5717a50f4e4964ea8423997d6456b04c653f0348/plugins/gist_tag.rb#L71-L107","documentation":"RuntimeError raised in get_gist_from_web (gist_tag.rb:88-90) after the plugin followed 301/302 redirects and the final HTTP status is still not 200. It means the request completed but GitHub (or a proxy in between) refused to serve the raw gist at the exact URL the plugin builds: https://gist.githubusercontent.com/raw/<gist_id>/<file>. Typical codes are 404 (bad/deleted/secret gist, wrong or missing filename) or 403/5xx from proxies and rate limiting. The tag raises during Liquid rendering, so the Jekyll build fails; a successful fetch would have been written to .gist-cache.","triggerScenarios":"Invoking {% gist <id> <file> %} where <file> is not the exact filename inside the gist; omitting the filename entirely, which makes get_gist_url_for produce a trailing-slash URL (https://gist.githubusercontent.com/raw/<id>/) that 404s; a typo'd, deleted, or secret gist id; ENV['http_proxy'] pointing at a proxy that returns 403/500; GitHub-side routing changes, since this vintage plugin hardcodes the retired /raw/<id>/<file> scheme.","commonSituations":"Old Octopress/Jekyll blogs whose embedded gists were deleted or made secret years later; CI builds behind corporate proxies or with no network egress; gist authors renaming or rewriting files; sites rebuilt after GitHub changed gist raw-URL routing, making every fetch 404 regardless of arguments.","solutions":["Open https://gist.githubusercontent.com/raw/<id>/<file> in a browser and correct the gist id and filename in the tag until it loads","Always pass the exact filename even for single-file gists: {% gist 1027674 gist_tag.rb %}, not {% gist 1027674 %}","Make sure the gist is public and still exists (re-create or fork it under your account and update the ids)","Populate .gist-cache with one successful build and commit it so CI and offline builds never hit the network","Replace this vintage plugin with the maintained jekyll-gist gem or plain <script src=...> embeds"],"exampleFix":"// before\n{% gist 1027674 %}\n\n// after\n{% gist 1027674 gist_tag.rb %}","handlingStrategy":"fallback","validationCode":"# Pre-flight the exact URL the tag will request\nrequire 'net/https'\nrequire 'uri'\n\ndef gist_url_ok?(gist_id, file)\n  uri  = URI(\"https://gist.githubusercontent.com/raw/#{gist_id}/#{file}\")\n  http = Net::HTTP.new(uri.host, uri.port)\n  http.use_ssl = true\n  code = http.head(uri.request_uri).code.to_i\n  code >= 200 && code < 400\nend","typeGuard":null,"tryCatchPattern":"code = get_cached_gist(gist, file)\nbegin\n  code ||= get_gist_from_web(gist, file)\nrescue RuntimeError => e\n  raise unless e.message.start_with?('Gist replied with')\n  code = get_cached_gist(gist, file) ||\n         \"<!-- gist #{gist}/#{file} unavailable: #{e.message} -->\"\nend\nhtml_output_for script_url, code","preventionTips":["Open https://gist.githubusercontent.com/raw/<id>/<file> in a browser before adding the tag","Always pass the exact filename, even for single-file gists","Own the gists you embed; if a gist must disappear, keep its files in .gist-cache","Commit .gist-cache so CI and offline builds take the cached path and skip the network","Replace this plugin with the maintained jekyll-gist gem"],"tags":["jekyll","gist","github","http-status","network","ruby"],"backgroundTag":"http-request-failed","analyzedSha":"5717a50f4e4964ea8423997d6456b04c653f0348","analyzedAt":"2026-08-21T17:21:26.485Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}