Reject HRRR downloads when server ignores Range header

S3 returns 200 with the full ~116MB file instead of 206 for some older
HRRR data. Treat this as a permanent failure instead of trying to parse
the entire file.
This commit is contained in:
Graham McIntire 2026-03-30 09:26:58 -05:00
parent 5c5d398966
commit 8e1fd702f9
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59
2 changed files with 6 additions and 1 deletions

View file

@ -178,9 +178,13 @@ defmodule Microwaveprop.Weather.HrrrClient do
Enum.map_join(ranges, ", ", fn {start, stop} -> "#{start}-#{stop}" end)
case Req.get(url, [{:headers, [{"Range", "bytes=#{range_header}"}]} | req_options()]) do
{:ok, %{status: status, body: body}} when status in [200, 206] ->
{:ok, %{status: 206, body: body}} ->
{:ok, body}
{:ok, %{status: 200}} ->
Logger.warning("HRRR server ignored Range header, returned full file")
{:error, "HRRR range request not supported"}
{:ok, %{status: status}} ->
{:error, "HRRR grib HTTP #{status}"}

View file

@ -69,6 +69,7 @@ defmodule Microwaveprop.Workers.HrrrFetchWorker do
defp permanent_failure?("HRRR idx HTTP 404"), do: true
defp permanent_failure?("HRRR grib HTTP 404"), do: true
defp permanent_failure?("HRRR range request not supported"), do: true
defp permanent_failure?(:outside_grid), do: true
defp permanent_failure?("malformed section"), do: true
defp permanent_failure?("missing sections: " <> _), do: true