Skip to content

Distinguish missing calibration file from no internet connection - #99

Merged
eliasbakken merged 1 commit into
mainfrom
fix/config-error-messages
Aug 10, 2026
Merged

Distinguish missing calibration file from no internet connection#99
eliasbakken merged 1 commit into
mainfrom
fix/config-error-messages

Conversation

@eliasbakken

Copy link
Copy Markdown
Contributor

Summary

create-recore-config previously reported a missing calibration file and a total network outage identically ("Unable to find the calibration file at the remote location"). These need different user action (check the serial number vs. check the connection), so report them separately - using wget's own exit codes (4 = network failure, vs. a reachable server returning an error) to tell them apart.

Also fixed updateConfig() to actually forward the script's specific message to the UI - it previously discarded it entirely and only sent the generic Go "exit status N".

Testing

  • make test-bats and go test ./... - no regressions.
  • Live-tested all three paths through the real UI /api/update_config call:
    • Valid serial + internet → OK
    • Serial with no matching calibration file → "No calibration file found for serial number 0499. Please check the serial number is correct."
    • No internet (simulated via a temporary /etc/hosts block on the calibration host) → "No internet connection. Setting the serial number requires internet access to download the calibration file."

Closes #83

create-recore-config previously reported both cases identically
("Unable to find the calibration file at the remote location") - a
genuinely missing calibration file for a given serial and a total
network outage look the same to the user, but need different action
(check the serial number vs. check the connection).

wget's own exit codes already distinguish these: 4 is a network
failure (no internet, DNS, connection refused), while a reachable
server returning an error (e.g. a real 404) exits differently. Use
that to report the two cases separately.

Also fixed updateConfig() to actually forward the script's message to
the UI - it previously only sent the generic Go "exit status N" from
runCommand2's error, discarding the script's specific, user-facing
reason entirely.

Live-tested on real hardware: verified all three paths through the
UI's actual /api/update_config call - valid serial + internet (OK),
serial with no matching calibration file (clear "check the serial
number" message), and no internet (simulated via /etc/hosts, clear
"internet access is required" message).

Addresses #83
@eliasbakken
eliasbakken merged commit 9194bc5 into main Aug 10, 2026
2 checks passed
@eliasbakken
eliasbakken deleted the fix/config-error-messages branch August 10, 2026 19:29
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.

Setting a serial number sometimes fails.

1 participant