From f005ddcaac04bedc398f751f00682e77fb1885ef Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Thu, 16 Apr 2026 09:38:26 -0500 Subject: [PATCH] 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. --- lib/microwaveprop/weather/narr_client.ex | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/microwaveprop/weather/narr_client.ex b/lib/microwaveprop/weather/narr_client.ex index b787794b..a170c8e9 100644 --- a/lib/microwaveprop/weather/narr_client.ex +++ b/lib/microwaveprop/weather/narr_client.ex @@ -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