fix(noaa): severe weather always reported zero — /alerts/active rejects limit - #129
Open
YAMRAJ13y wants to merge 1 commit into
Open
fix(noaa): severe weather always reported zero — /alerts/active rejects limit#129YAMRAJ13y wants to merge 1 commit into
limit#129YAMRAJ13y wants to merge 1 commit into
Conversation
…ts `limit`
`getActiveAlerts()` always sent `limit` to `api.weather.gov/alerts/active`,
which the endpoint does not accept. The upstream reply is explicit:
HTTP 400
{"parameter": "query.limit",
"message": "Query parameter \"limit\" is not recognized"}
`safeFetch` resolves to `{ error }` rather than throwing, so `alerts?.features
|| []` collapsed to an empty array and the source reported a confident
all-clear on every sweep since the parameter was added:
"totalSevereAlerts": 0,
"summary": { "hurricanes": 0, "tornadoes": 0, "floods": 0,
"winterStorms": 0, "wildfires": 0, "other": 0 }
with no error field anywhere in the payload. At the time of this commit the
same query without `limit` returns 33 active severe alerts, including a live
Severe Thunderstorm Warning and 26 Extreme Heat Warnings.
Drop the parameter. `/alerts/active` only ever returns currently-active
alerts, so the response is naturally bounded and no client-side cap is
needed — capping would under-report `totalSevereAlerts` during exactly the
severe-weather outbreaks this source exists to catch.
Also pass through `alerts.error` so a future upstream failure is visible in
the payload instead of silently rendering as "no severe weather anywhere in
the US". Same bug class, four lines; happy to split it out if preferred.
Verified: 0 -> 33 alerts against the live API; forced-failure path now
surfaces the error; `node --test test/*.test.mjs` 45 pass / 1 skipped.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The NOAA/NWS source has been reporting zero severe weather alerts on every sweep. It sends a
limitquery parameter thatapi.weather.gov/alerts/activedoes not accept, so every request fails with HTTP 400 and the source silently returns an all-clear.Why
getActiveAlerts()builds?limit=50&status=actual&severity=Extreme,Severe. The endpoint rejects it, and says so explicitly:safeFetchresolves to{ error }instead of throwing, soalerts?.features || []collapses to[]andbriefing()produces a clean-looking payload with no error field anywhere:That is the failure mode that matters here: not a visible outage, but a dead source that looks like good news. The dashboard's
noaa.totalAlertsreads 0, no map markers are drawn, and nothing in/api/healthindicates a problem.Dropping the parameter restores the source. Same command on this branch, at the time of writing:
{ "source": "NOAA/NWS", "totalSevereAlerts": 33, "topAlerts": [ { "event": "Severe Thunderstorm Warning", "severity": "Severe", "urgency": "Immediate", "lat": 43.676, "lon": -89.516, "headline": "Severe Thunderstorm Warning issued August 9 at 9:00AM CDT ..." }, ... ] }33 active alerts — 26 Extreme Heat Warnings, 5 Red Flag Warnings, 1 Severe Thunderstorm Warning, 1 Extreme Heat Watch.
Notes on the approach
Why remove
limitrather than apply it client-side./alerts/activeonly ever returns currently-active alerts, so the response is naturally bounded. Capping client-side would under-reporttotalSevereAlertsduring exactly the severe-weather outbreaks this source exists to catch. Nothing in the repo passeslimit—getSevereAlerts()only setsseverity— so removing the option is not a breaking change for any caller.The four-line error passthrough.
briefing()now includesalerts.errorwhen the request fails, so the next upstream change surfaces instead of rendering as "no severe weather anywhere in the US". It is the same bug class rather than a second feature, and it is additive so it cannot break the dashboard'stotalSevereAlerts/topAlertsconsumers indashboard/inject.mjs:459. Happy to split it into its own PR if you would rather keep this to the one-line parameter fix.Out of scope, noticed while testing: the
summarybuckets have no category for heat or fire-weather alerts, so today all 33 land inother(/fire/idoes not match "Red Flag Warning"). That is a taxonomy decision rather than a bug, so I left it alone — happy to open a separate issue.Scope
Validation
Config and Docs
.env.exampleunchanged — NOAA needs no keyREADME.mdunchanged — this restores documented behaviour