Skip to content

fix(radar): handle empty/unknown VCP without aborting station processing#123

Merged
jacaudi merged 3 commits into
mainfrom
fix/121-unknown-vcp
May 6, 2026
Merged

fix(radar): handle empty/unknown VCP without aborting station processing#123
jacaudi merged 3 commits into
mainfrom
fix/121-unknown-vcp

Conversation

@jacaudi
Copy link
Copy Markdown
Owner

@jacaudi jacaudi commented May 5, 2026

Summary

Three-commit branch resolving #121 plus tightening the VCP data layer it touched.

  1. fix(radar): handle empty/unknown VCP without aborting station processing (c623fe0)

    • Adds ErrUnknownVCP sentinel; GetMode returns ("Unknown (VCP %q)", wrapped sentinel) for empty/unknown codes
    • FetchData checks errors.Is(err, ErrUnknownVCP) → logs WARN with the raw VCP and continues, so status/generator/operability still get processed
    • Drops the redundant radar.GetMode() call in monitor.processStation that would have re-raised the hard error and defeated the soft-handle
  2. refactor(radar): replace VCP switch with typed catalog map (e2a91ff)

    • Introduces VCPInfo {Mode, Description} and a package-level vcpCatalog map keyed by VCP code
    • GetMode is now a map lookup; new GetVCPInfo exposes the description for richer logging/alerts
    • The catalog populates each known VCP's meaning inline as structured data rather than only as comments
  3. refactor(radar): fold getVCPDescription into vcpCatalog as AlertText (dbce801)

    • Adds AlertText to VCPInfo and removes the parallel hand-rolled getVCPDescription map in compare.go
    • CompareData now uses GetVCPInfo to surface the alert prose
    • User-facing Pushover text is byte-identical to before for all six known VCPs

Why

Production prod log on 2026-05-05 14:11 UTC: level=ERROR msg="Failed to process station: error fetching radar data for station KATX: unknown mode for VCP -- please update code" — KATX returned an empty VCP from NWS, causing the entire station's poll cycle to be aborted at ERROR level. Empty VCP is a transient/benign state; other fields still carry useful state and should continue to be compared.

Pushover behavior preview (verified against this branch)

Startup

  • KATX Seattle - Precipitation Mode (R212)
  • KATX Seattle - Clear Air Mode (R31)
  • KATX Seattle - Unknown (VCP "") Mode (empty VCP, post-fix)

Change (title: KATX Update)

  • VCP R31 → R212: Precipitation Mode Active
  • VCP R12 → R215: Precipitation Mode (Vertical Scanning Emphasis) Active
  • VCP R212 → R112: Precipitation Mode (Velocity Scanning Emphasis) Active
  • VCP changes to unknown future code (R45): Radar mode changed from R212 to R45
  • Status/Operability/Power/Generator changes: existing from X to Y strings, unchanged
  • Radar PNG is attached only when VCP changed

Test plan

  • go test ./... — all packages pass
  • go vet ./... — clean
  • TestGetMode extended for empty / whitespace / R99 (asserts errors.Is(err, ErrUnknownVCP) + fallback label contains the raw VCP)
  • TestGetVCPInfo covers known + unknown paths
  • Existing compare_test.go assertions on "Precipitation Mode Active" / "Clear Air Mode Active" continue to pass after the catalog refactor

Closes #121

jacaudi and others added 3 commits May 5, 2026 11:37
GetMode now returns a fallback "Unknown (VCP %q)" label and the
ErrUnknownVCP sentinel for empty or unrecognized VCP codes. FetchData
treats this as a soft condition: logs a WARN and continues with the
fallback so the rest of the station data (status, generator state,
operability) still gets processed and compared.

Also drops the redundant radar.GetMode() call in monitor.processStation
that re-derived the same mode FetchData had already populated; the
duplicate call would have re-raised the same hard error and defeated
the soft-handle.

Closes #121

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Introduce VCPInfo {Mode, Description} and a package-level vcpCatalog
map keyed by VCP code. GetMode now does a map lookup; GetVCPInfo is
added so callers can surface the description (mode cycle, scan pattern
notes) for richer logs/notifications later.

The catalog populates the meaning of each known VCP inline as
structured data rather than only as comments.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The compare path had its own hand-rolled VCP→prose map
(getVCPDescription) parallel to vcpCatalog. Adding a new VCP required
edits in two places, with no compiler help to keep them in sync.

Add an AlertText field to VCPInfo and populate it for each catalog
entry; CompareData now uses GetVCPInfo to look up the alert text. The
prose surfaced to Pushover is unchanged for all current VCPs:

  R31, R35    -> "Clear Air Mode Active"
  R12, R212   -> "Precipitation Mode Active"
  R112        -> "Precipitation Mode (Velocity Scanning Emphasis) Active"
  R215        -> "Precipitation Mode (Vertical Scanning Emphasis) Active"

Unknown VCPs continue to fall through to "Radar mode changed from X to Y".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jacaudi jacaudi merged commit bbd2292 into main May 6, 2026
10 checks passed
@jacaudi jacaudi deleted the fix/121-unknown-vcp branch May 6, 2026 07:03
@wall-e-one
Copy link
Copy Markdown
Contributor

wall-e-one Bot commented May 6, 2026

🎉 This PR is included in version 2.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

renderer/dras: handle empty/unknown VCP from NWS metadata

1 participant