Distinguish missing calibration file from no internet connection - #99
Merged
Conversation
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
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
create-recore-configpreviously 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-batsandgo test ./...- no regressions./api/update_configcall:OK"No calibration file found for serial number 0499. Please check the serial number is correct."/etc/hostsblock on the calibration host) →"No internet connection. Setting the serial number requires internet access to download the calibration file."Closes #83