Skip to content

refactor: Return unexpected errors from IsActive and IsEnabled#107

Merged
bketelsen merged 1 commit intomainfrom
yeti/improve-d16c
Mar 31, 2026
Merged

refactor: Return unexpected errors from IsActive and IsEnabled#107
bketelsen merged 1 commit intomainfrom
yeti/improve-d16c

Conversation

@frostyardyeti
Copy link
Copy Markdown
Contributor

@frostyardyeti frostyardyeti Bot commented Mar 31, 2026

In systemd/runner.go, both IsActive (line 52) and IsEnabled (line 67) return false, nil for all errors after checking for expected exit codes. This silently swallows unexpected failures such as systemctl not being found on $PATH, permission denied, or unknown exit codes.

For example in IsActive (lines 42-55), after handling exit code 3 (inactive), the fallthrough return false, nil on line 52 hides any other error. The same pattern on line 67 in IsEnabled hides errors beyond exit code 1.

The fix: change the fallthrough return false, nil to return false, err in both functions so callers can distinguish between "unit is not active" and "we couldn't determine the state".


Automated improvement by yeti improvement-identifier

The fallthrough error paths in both functions returned false, nil for all
errors, silently swallowing failures like systemctl not found, permission
denied, or unknown exit codes. Change to return false, err so callers can
distinguish "unit is not active/enabled" from "we couldn't determine the
state".

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bketelsen bketelsen merged commit 536dcb2 into main Mar 31, 2026
7 checks passed
@bketelsen bketelsen deleted the yeti/improve-d16c branch March 31, 2026 03:06
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.

1 participant