NarrClient: include cdo output snippet in parse-failure errors

Prod hit "no parseable values in cdo output" for a 2007 record.
Without the actual cdo output it's guesswork whether it's a different
parameter-table format, an empty result, or something else. Capture
stderr (stderr_to_stdout: true) and include first 500 chars of output
so the error message has enough signal to diagnose.
This commit is contained in:
Graham McIntire 2026-04-16 09:38:26 -05:00
parent a2cdee7a31
commit f005ddcaac
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -294,7 +294,7 @@ defmodule Microwaveprop.Weather.NarrClient do
grb_path
]
case System.cmd("cdo", args, stderr_to_stdout: false) do
case System.cmd("cdo", args, stderr_to_stdout: true) do
{stdout, 0} ->
parse_cdo_outputtab(stdout)
@ -312,7 +312,11 @@ defmodule Microwaveprop.Weather.NarrClient do
|> Enum.reduce(%{}, &accumulate_cdo_row/2)
if raw == %{} do
{:error, "NARR cdo extract: no parseable values in cdo output"}
# Include the first 500 chars of cdo output so the error surfaces
# what cdo actually printed — crucial for diagnosing year-specific
# parameter-table quirks in NARR GRIB1.
snippet = stdout |> String.slice(0, 500) |> String.replace("\n", " | ")
{:error, "NARR cdo extract: no parseable values in cdo output (got: #{snippet})"}
else
{:ok, build_profile_attrs(raw)}
end