power: return the unsure state from the shellcmd driver - #609
Merged
chombourger merged 1 commit intoAug 24, 2026
Conversation
The documented contract for check-on is "Should return 0 if power is on, 1
if it is off. Any other return code is interpreted as error". The error
branch evaluates self.POWER_UNSURE without returning it, so status() yields
None instead.
That None reaches the user: the gRPC servicer sends str(result or ''), so
`mtda-cli target status` prints an empty line where it should print ??? .
check-on exit=0 ON ON
check-on exit=1 OFF OFF
check-on exit=2 None '' <- should be ???
check-on exit=127 None '' <- should be ???
Verified by driving the controller with subprocess.run patched.
Signed-off-by: George Vasiliades <1221374+Poseidonas@users.noreply.github.com>
Collaborator
|
good catch and thanks for being so thorough (e.g. use of AST to check for similar issues in the code tree) |
chombourger
approved these changes
Aug 24, 2026
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.
docs/config.rstdescribescheck-onas:The error branch in
ShellCmdPowerController.status()evaluatesself.POWER_UNSUREwithout returning it, so the method falls through and yieldsNone.That
Nonereaches the user rather than staying internal.grpc/servicer.py:478sendsstr(result or ''), somtda-cli target statusprints an empty line where the documentation says it should report an unknown state.Driving the controller with
subprocess.runpatched, before and after:The change is the missing
return.I scanned the rest of the tree with the AST for the same shape — a bare
self.Xexpression statement where areturnwas meant — and this is the only occurrence.flake8is clean with the exclusions fromtox.ini. I could not runscripts/test-using-dockerhere (thearchlinuximage has nolinux/arm64manifest, andmtda-serviceimportssystemd, which is not installable on macOS), so this rests on the isolated check above.Found while looking at #596, which turns out to be already fixed by 9b2890e — the documentation now reads correctly, but the code no longer matches it in this one branch. Worth closing #596 if it was left open by oversight.