← Back to issue list

Use predefined exit codes

View original Github issue

Metadata

Project
craft-application
Number
#379
Type
issue
State
open
Author
mattculler
Labels
Created
Updated
Closed

Current evaluation

Refactor request to replace hardcoded sysexits.h magic numbers with os.EX_* constants in application.py, errors.py, remotebuild.py, and to expose error exit codes for tests. PR #387 merged and fixed the simple cases; 128+SIGINT and a few magic numbers (77/75) remain.

Suggested action: keep open

Reason: PR #387 (merged, commit e8651e46) resolved the main body of the issue — application.py, errors.py, and services/remotebuild.py now use os.EX_* constants — but the follow-up items from the comments remain unaddressed: application.py:440 and util/logging.py:65 still use bare 128 + signal.SIGINT, and commands/remote.py still hardcodes retcode=77 and return 75 with explanatory comments, exactly the anti-pattern the issue targets. The work is small and well-scoped, so it merits keeping open rather than closing as stale.

Impact: 15 Quick Win: 12.75 Staleness: 72 Complexity: 15 Confidence: 80 Support Request: 0

Issue body

### What needs to get done In `application.py` (as well as `errors.py` and `services/remotebuild.py`) there are hardcoded constants that refer to `sysexits.h`. These constants are already defined in the python standard library under `os`: https://docs.python.org/3/library/os.html#os.EX_OK More pedantic, less important: `PartsError` and `ProviderError` both exit 1 - whether these are changed to something more distinctive or not, these should be defined publically, so the values can be used in unit tests. `CraftError` exits an overrideable value that it defines internally as defaulting to 1, this can also be exposed for tests. ### Why it needs to get done Using predefined values is better practice than using magic numbers with explanatory comments.

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 15
Quick Win: 12.75
Staleness: 72
Complexity: 15
Confidence: 80
Support Request: 0
keep open Refactor request to replace hardcoded sysexits.h magic numbers with os.EX_* constants in application.py, errors.py, remotebuild.py, and to expose error exit codes for tests. PR #387 merged and fixed the simple cases; 128+SIGINT and a few magic numbers (77/75) remain.
qwen/qwen3.6-35b-a3b
Staleness: 90
Complexity: 15
Confidence: 85
Support Request: 0
close stale Refactor request to replace hardcoded exit codes with standard os.EX_* constants and expose error exit codes for testing. Partially addressed via PR #387, but stalled for over a year with no further maintainer action.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 20
Confidence: 70
Support Request: 5
needs triage Suggests replacing hardcoded exit codes with Python os module constants and exposing error codes for testing. PR 387 handles simple cases, but signal-based exit codes remain unresolved. Unlabelled and inactive for over a year.
qwen3.6-35b-a3b-mtp-q6
Staleness: 80
Complexity: 15
Confidence: 80
Support Request: 0
close stale Replace hardcoded exit codes with Python's os.EX_* constants and expose error codes for testing. PR #387 handles simple cases, but 128 + signal.SIGINT mappings remain under discussion. Awaiting resolution.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: canonical/craft-application#387 (confidence 85%)

    Merged PR 'refactor: use exit code constants when possible' explicitly noted as partially resolving this issue; it converted the simple os.EX_* cases in application.py, errors.py, and remotebuild.py.

Related issues

No related issues found above the similarity threshold.