Skip to content

Fix dashboard showing "n/a" for a legitimate 0.0 °C reading - #92

Merged
LarsLaskowski merged 1 commit into
mainfrom
claude/issue-64-yzq8i2
Aug 18, 2026
Merged

Fix dashboard showing "n/a" for a legitimate 0.0 °C reading#92
LarsLaskowski merged 1 commit into
mainfrom
claude/issue-64-yzq8i2

Conversation

@LarsLaskowski

@LarsLaskowski LarsLaskowski commented Aug 18, 2026

Copy link
Copy Markdown
Owner

📖 Description

app.js gated the temperature display on snap.temperature?.celsius truthiness (internal/web/assets/app.js:221, formerly if (snap.temperature && snap.temperature.celsius)). Since 0 is falsy in JavaScript, a legitimate exact 0.0 °C reading (plausible for a Pi in an unheated/outdoor enclosure) was indistinguishable from a failed sensor read and rendered as "n/a".

The root cause is that the API always marshals Snapshot.Temperature, and a failed collection yields {"zone": "", "celsius": 0} — so a successful reading is actually distinguished by a non-empty zone, not by the celsius value. This fix keys the frontend check off snap.temperature?.zone instead, per the fix suggested in the issue for a non-breaking, within-v1 change.

The longer-term fix (making Temperature a pointer, omitted on failure like gpu_temperature) is a breaking API change and is left for /api/v2/, as noted in the issue.

This is a frontend-only change; no Go API types were touched.

🎫 Issues

Closes #64

👩‍💻 Reviewer Notes

Single-line fix in internal/web/assets/app.js. No build step for the frontend (plain JS embedded via go:embed), so the fix is the diff itself — no bundler artifacts to check.

📑 Test Plan

There is no JS test runner in this repository (see docs/TESTS.md); internal/web/xss_test.go establishes the pattern of a Go test scanning the embedded app.js source for a banned/required construct, so I followed that pattern:

  • Added internal/web/temperature_test.go (TestAppJS_TemperatureNAUsesZoneNotCelsius), which fails if app.js reintroduces a celsius-truthiness gate on the "n/a" fallback, and asserts the zone-based check is present.
  • go build ./..., go vet ./..., go test ./... -race -cover, and golangci-lint run all pass locally.

✅ Checklist

General

  • I have added/updated tests for my changes (go test ./... -race -cover passes locally).
  • go vet ./... and golangci-lint run are clean.
  • I have tested my changes.
  • I have read the CONTRIBUTING documentation and followed the project's code style guidelines.
  • I have updated ARCHITECTURE.md if this changes a documented design decision. (not applicable — no documented design decision changed)

REST API / configuration / packaging

Not applicable — this is a frontend-only fix; the /api/v1/... response shape (Temperature.Celsius always marshaled) is unchanged.

⏭ Next Steps

The longer-term API fix noted in the issue — making Temperature a pointer so a failed reading is null/omitted instead of {"zone": "", "celsius": 0} — is a breaking change and would need to land under /api/v2/.... Not addressed here.

app.js gated the temperature display on `snap.temperature?.celsius`
truthiness, so an exact 0 °C reading (plausible for a Pi in an
unheated/outdoor enclosure) rendered as "n/a" indistinguishably from a
failed sensor read. A successful reading always carries a non-empty
zone, while a failed collection yields zone: "", so key off
`snap.temperature?.zone` instead.

Closes #64
@sonarqubecloud

Copy link
Copy Markdown

@LarsLaskowski
LarsLaskowski merged commit 2b5904f into main Aug 18, 2026
5 checks passed
@LarsLaskowski
LarsLaskowski deleted the claude/issue-64-yzq8i2 branch August 18, 2026 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: a legitimate 0.0 °C reading renders as "n/a"; API cannot distinguish 0 °C from a failed sensor

2 participants