Repository navigation
Description
What happened
docs/TESTING.md says: "A test of an error path checks the DevOpsCLIError subclass raised, with its exit code and machine-readable error code." At b170358, 200 pytest.raises calls in 85 test files name a project or library error type, pass no match=, and keep no handle to the error, so they check only the type. A test of an error path then passes when the code raises the right type for the wrong reason.
The most common types: ValidationError (33), SSRFBlockedError (24), typer.Exit (23), SecurityError (15), AIClientError (7), ServiceAddressError (7), asyncio.CancelledError (6), SandboxNotFoundError (5). The files with the most sites: tests/test_validation.py (21), tests/test_process.py (15), tests/test_http_egress.py (10), tests/test_http_broker.py (7), tests/test_ai_client_providers_and_embeddings.py (6).
What should happen
- A
pytest.raisesof aDevOpsCLIErrorsubclass keeps the error (as raised) and checks itserror_code, and its exit code where the command layer maps one. - A
pytest.raisesof a library error passesmatch=with the message that only the expected failure gives. Atyper.Exitcheck reads its exit code. - A check stops new cases: ruff's
PT011, withraises-require-match-forextended to these types, or an ast-grep rule in theconstructsrow.
Evidence
- An AST pass over
tests/at b170358:pytest.raises(X)whereXis not a built-in exception, with nomatch=keyword and noastarget. 200 sites in 85 files. The script and its list are in.data/agent/scratch/audit-issues/of the 2026-10-24 audit. docs/TESTING.md, "Names and assertions".
Acceptance criteria
- Each of the 200 sites checks the
error_code(and exit code) of aDevOpsCLIError, the message of a library error, or the code of atyper.Exit. - A check in
devops cifails a newpytest.raisesthat checks only the type. The pull request shows it failing on a scratch case. - The tests patch nothing new and import no private name.
-
uv run devops cipasses.
Related: #2171 owns the tests with no assertion and the built-in pytest.raises with no match=. #1307's children change these files for other reasons; a site that a child rewrites first leaves this item.
Source: #2171
Proposed design
Problem statement
200 pytest.raises calls in 85 test files check only the exception type. They do not verify the error code, exit code, or message. A test then passes when the code raises the right type for the wrong reason. The fix adds the missing assertion at each site. It also adds a static check that fails a new bare pytest.raises.
Acceptance criteria
- Criterion 1: Each of the 200 sites checks the error_code of a DevOpsCLIError, the message of a library error, or the code of a typer.Exit.
Verification: Run the AST audit over tests/ and confirm zero sites with a project or library error type, no match=, and no as target. - Criterion 2: A static check in devops ci fails a new pytest.raises that checks only the type.
Verification: Add a scratch test with a bare pytest.raises(ValidationError) and confirm uv run devops ci fails on it. - Criterion 3: The tests add no new patch and import no private name.
Verification: uv run devops ci passes, including the invariants that check for new patches and private imports. - Criterion 4: uv run devops ci passes.
Verification: Run uv run devops ci and confirm all checks pass.
Key questions
- What attributes does DevOpsCLIError expose for the assertion?: It has an error_code and an exit code. TESTING.md states the test checks the subclass with its exit code and machine-readable error code. [sources: docs/TESTING.md]
- Which static check mechanism prevents new violations?: Either ruff PT011 with raises-require-match-for extended to the project error types, or an ast-grep rule in the constructs row. The repository already runs ast-grep rules such as test-elapsed-upper-bound in .ast-grep/rules/. (proposed) [sources: docs/TESTING.md]
- How does a test check a typer.Exit?: It keeps the exception with as raised and asserts on raised.code. [sources: tests/test_validation.py]
- How does a test check a library error such as asyncio.CancelledError that has no distinctive message?: The test passes match= with the message the failure gives, or keeps the exception with as and asserts on a distinguishing attribute. The surrounding test context and post-conditions already distinguish the expected failure. (proposed) [sources: tests/test_process.py]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsReady
- StatusShow more project fieldsNew
Activity
dan-petty commentedon Oct 24, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.
The candidate proposes changes to test assertions for error paths, which is a test-related task.This change improves test accuracy and reliability but does not fix a critical issue or add a major feature.Improving test quality helps prevent false positives in error handling and strengthens the project's reliability.The change requires modifying 200 test cases across multiple files, but it follows a clear pattern that can be automated.Both items work on error handling but item 1006 focuses on mapping exceptions to exit codes and consolidating the error classes while this candidate checks more thoroughly in tests.dan-petty commentedon Oct 28, 2026
Status set to Ready at bb46660 (see proposed design in issue body).
test(cli): tests check error code exit code or match
test(cli): tests check error code exit code or match