Repository navigation
fix(oracle): make KiCadNotFound an environment fault, not exit 1 - #21
Merged
Merged
Conversation
KiCadNotFound and EnvironmentError_ were siblings, both RuntimeError. main converts EnvironmentError_ to exit 4 in one place, so a discovery failure escaped that handler at any call site that did not wrap it. check, gate and netlist survived only because each wraps the failure itself. doctor calls find_kicad_cli() directly, so nothing converted it: it crashed with an unhandled traceback at exit 1 -- which is EXIT_VIOLATION, the code reserved for "the design is wrong". A caller treating nonzero-but-not-4 as a finding read a missing KiCad as a bad board, which is the exact confusion the exit codes exist to prevent. It is also the first command anyone runs on a new machine. Subclassing fixes doctor and every future direct caller, rather than only the one path a local wrap would cover. Closes #18
Connectivity unchanged
|
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.
KiCadNotFoundandEnvironmentError_were siblings, bothRuntimeError.mainconverts
EnvironmentError_to exit 4 in one place (cli.py:57), so a discoveryfailure escaped that handler at any call site that did not wrap it itself.
check,gateandnetlistsurvived only because each wraps the failure locally(
cli.py:172,:256,:319).doctorcallsfind_kicad_cli()directly atcli.py:126, so nothing converted it.Why exit 1 is the wrong code, specifically
Exit 1 is
EXIT_VIOLATION-- the code reserved for "the design is wrong". A callerthat treats nonzero-but-not-4 as a finding read a missing KiCad as a bad board,
which is the exact confusion the exit codes exist to prevent. And it happened in the
one subcommand whose stated purpose is to tell you whether an engine can be found,
on the first command anyone runs on a new machine.
Verified
Reproduced on a PATH with no
kicad-cliand no Flatpak, before:After:
which now matches
check/gate/netliston the same machine.Approach
Subclassing rather than wrapping inside
_doctor, per the issue's suggesteddirection: it fixes
doctorand every future call site that reaches discoverydirectly, where a local wrap would leave the next direct caller with the same bug.
test_oracle.py:22already catches(KiCadNotFound, EnvironmentError_)as a tuple,so it keeps working unchanged.
Tests
Three added to
test_boundaries.py, where the structural invariants live: thesubclass relationship,
doctorreturningEXIT_ENVIRONMENT, and a parametrizedcheck that every engine-needing subcommand agrees on exit 4. All three confirmed to
go red with the source change reverted and the tests kept.
just checkandjust testgreen: 230 passed, 6 skipped (baseline 227).Closes #18