Skip to content

fix(cli): every command reports a DevOpsCLIError through one exit seam - #2502

Merged
dan-petty merged 3 commits into
mainfrom
fix/2487-one-exit-seam
Oct 28, 2026
Merged

dan-petty merged 3 commits into
mainfrom
fix/2487-one-exit-seam

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Every devops command now reports a DevOpsCLIError in one way. The wrapper of new_typer() (OTelTyper.command) reports each DevOpsCLIError that a command raises: it prints the error's message in one error line, with any Rich markup in it escaped, and exits with the error's exit_code, with no traceback. OTelTyper.callback does the same for a callback that runs as a command (devops benchmark, devops dashboard).

Before, a command reported the error in four ways: exit_on= on 18 apps, 41 exit_on_error blocks, 21 hand-rolled raise typer.Exit(exc.exit_code) handlers, or not at all. A DevOpsCLIError that no block caught ended the command with a traceback and status 1, not with its own status. devops docker sandbox --dry-run on a refused workspace was one example.

  • OTelTyper loses exit_on, and exit_on_error becomes the private _report_devops_error of the wrapper.
  • The exit_on= arguments, the exit_on_error blocks and the hand-rolled handlers are deleted, with _print_cloudflare_error and _print_valkey_error, which had no caller left.
  • commands/config.py builds its app with new_typer(), so its commands pass through the seam and get the cli.<command> span, which holds no parameter value.
  • A Cloudflare, Valkey, sandbox-logs or SBOM error prints its own message, without the text that its handler put before it ("Valkey ping failed: "). The exit status of each error class stays the same.
  • An exception that is not a DevOpsCLIError propagates as before.
  • Tests: a command and a callback that raise an error with markup exit with its status in one line; every registered command app is an OTelTyper; a source invariant refuses exit_on=, exit_on_error and a hand-rolled typer.Exit(exc.exit_code) under commands/.
  • ARCHITECTURE.md and CONTRIBUTING.md describe the seam.

This is part 1 of #1006. Part 2, #2490, moves the error codes onto the exception classes.

Closes #2487

Change: openspec/changes/archive/2026-10-28-2487-one-exit-seam/

The wrapper of new_typer() reports each DevOpsCLIError that a command,
or a callback that runs as a command, raises: one error line with the
markup of its message escaped, the error's exit status, and no
traceback. Before, a DevOpsCLIError that no block caught ended the
command with a traceback and status 1.

- OTelTyper loses exit_on, and exit_on_error becomes the private
  _report_devops_error of the wrapper.
- The exit_on= arguments of 18 apps, 41 exit_on_error blocks and 21
  hand-rolled `raise typer.Exit(exc.exit_code)` handlers are deleted,
  with the two error printers that they left without a caller.
- The config app is a new_typer() app, so its commands pass through the
  seam.
- A Cloudflare, Valkey, sandbox-logs or SBOM error now prints its own
  message without the text the handler put before it. Each exit status
  stays the same.
@dan-petty

Copy link
Copy Markdown
Owner Author

Test evidence:

  • uv run devops ci fail-to-pass --base origin/main: 49 failed on base, 267 passed, 0 errored. On base, the new command and callback tests ended with status 1 and the escaped exception, the app walk found config: Typer, the source invariant listed the exit_on=, exit_on_error and hand-rolled sites, and the sandbox refusal tests (42 cases) got the escaped DockerSandboxError.
  • uv run devops ci test (full suite, before the rebase onto 0137f23): 11786 passed in 3 m 52 s.
  • After the rebase, main had three new exit_on=SSRFBlockedError apps (argo, grafana, prometheus) and one exit_on_error block in argo. Both error classes are DevOpsCLIError subclasses, so the seam reports them. The changed and affected tests, with the argo, Prometheus and Grafana tests, pass: 524 passed.
  • uv run mypy on the changed source: no issues. tests/test_swallowed_failures_ratchet.py: passed, because each deleted handler raised again.
  • An AST walk found no enclosing try around any removed block or handler, and none at the call sites of the helpers that held one.

Pending a person: run a devops cloudflare and a devops valkey command that fails on a missing token, and check that each prints one error line and exits with the same status as before. Review the diff in tuicr (tuicr -r origin/main..HEAD).

@dan-petty
dan-petty force-pushed the fix/2487-one-exit-seam branch from 7b9ae9f to 29ee200 Compare October 28, 2026 19:12
@dan-petty
dan-petty marked this pull request as ready for review October 28, 2026 19:18
@dan-petty
dan-petty merged commit eadd55f into main Oct 28, 2026
18 checks passed
@dan-petty
dan-petty deleted the fix/2487-one-exit-seam branch October 28, 2026 19:38
dan-petty pushed a commit that referenced this pull request Oct 28, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.11.0](v0.10.1...v0.11.0)
(2026-10-28)


### Features

* **monitoring:** the roadmap Service's identity refusals, failing and
stalled jobs, restarts, and GitHub and model request volume raise alerts
([#2496](#2496))
([0137f23](0137f23)),
closes [#2472](#2472)
* **service:** roadmap-service runs at one replica, and each model call
in the cluster is sent at most two times
([#2500](#2500))
([2d32dae](2d32dae)),
closes [#2494](#2494)


### Bug Fixes

* **cli:** every command reports a DevOpsCLIError through one exit seam
([#2502](#2502))
([eadd55f](eadd55f)),
closes [#2487](#2487)
* **github:** pr monitor waits until the checks settle and names every
blocker, and pr ready reads the merge-readiness verdict
([#2498](#2498))
([43326ea](43326ea))
* **k8s:** a pod that does not call the Kubernetes API mounts no service
account token
([#2522](#2522))
([305d3ba](305d3ba))
* **k8s:** the cloudflared tunnel replicas prefer different nodes and
keep one up through a drain
([#2499](#2499))
([d4edaf6](d4edaf6)),
closes [#1023](#1023)
* **k8s:** the grafana, prometheus, argo cd and loki clients dial
through the egress-checked factory, and their pre-flight address checks
go ([#2497](#2497))
([e7ca1d5](e7ca1d5))
* **monitoring:** the roadmap Service alerts count a series that starts
in the hour, and a lane of a new pod can stall
([#2514](#2514))
([c7692b2](c7692b2)),
closes [#2505](#2505)
* **review:** a review's scanners leave out the rules that never gave a
valid finding here
([#2508](#2508))
([fe953ac](fe953ac))
* **roadmap:** a refine round leaves an outside account issue to a
person, and refine neutralizes comment openers, www links and
cross-repository references
([#2507](#2507))
([e6230dc](e6230dc)),
closes [#2478](#2478)
* **sandbox:** the metrics scrape and the whitelist NetworkPolicy
resolve each host one time, through the egress check
([#2521](#2521))
([7c01426](7c01426))
* **security:** the subprocess environment guard refuses the zsh and
interpreter keys that make a child run code
([#2510](#2510))
([459621a](459621a))
* **service:** a restart keeps the halt, the budget window and the
failure ledger, and a rate limit or a suspended installation stops every
worker ([#2515](#2515))
([3630de1](3630de1)),
closes [#2474](#2474)


### Code Refactoring

* **config:** settings resolve in one declared order through
pydantic-settings sources
([#2518](#2518))
([6a5447a](6a5447a)),
closes [#2445](#2445)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
dan-petty added a commit that referenced this pull request Oct 28, 2026
… address

A command of each `devops cloudflare` group runs against
api.cloudflare.com, whose DNS answer is 10.0.0.1. The client refuses
the address at the connect and raises SSRFBlockedError. The test expects
the command to print the message of SSRFBlockedError and to exit with
its exit code, 2, with no traceback, and expects no dial to 10.0.0.1.
The exit seam of OTelTyper.command (#2502) reports the error. Before the
client fix, the client sent the request with no address check, and the
command exited with code 1, so the rows fail on that code.
dan-petty added a commit that referenced this pull request Oct 28, 2026
…efused cloudflare request

The exit seam of new_typer() (#2502) reports each DevOpsCLIError that a
command raises. SSRFBlockedError is a DevOpsCLIError. Thus a
`devops cloudflare` command prints the refusal and exits with code 2,
with no traceback, and commands/cloudflare.py does not change. The
design decision, the rejected alternative, the proposal and the task of
2430 name the seam. The requirement of public-api-egress stays the same.

The feasibility record names the new base, 305d3ba, and records that
the socket gets neither 10.0.0.1 nor api.cloudflare.com on the fixed
code, and the host name on the code before the move.
dan-petty added a commit that referenced this pull request Oct 28, 2026
…o main

The branch was rebased onto main after #2502 deleted exit_on. This merge keeps the old commits of the remote branch, so that the push does not rewrite the remote history. The merge uses the strategy ours: the tree is the tree of the rebased branch.
dan-petty added a commit that referenced this pull request Oct 28, 2026
…dial through the egress-checked factory at the public level (#2509)

The clients of four fixed public APIs get their HTTP client from the
egress-checked factory (`devops_cli.http.client`) at the public level:
the OSV lookup (`api.osv.dev`), the Shodan InternetDB lookup
(`internetdb.shodan.io`), the Cloudflare Radar lookup and the Cloudflare
API client (`api.cloudflare.com`). Before, each client built a raw
`httpx2.Client`. httpx2 resolved the API host at the socket and dialled
each answer with no check. Thus a bad or rebinding DNS answer could send
the request to a loopback, private or link-local address. For the
Cloudflare clients, the request also sent the Cloudflare API token to
that address.

- Each client resolves its API host one time, at the connect, and dials
only a public address. `ai.allow_private_network` does not change this
level. Cloud metadata addresses are refused at every level. The factory
checks each redirect hop in the same way. The timeouts do not change.
- A refused lookup of OSV, InternetDB or Radar gives the same result as
a failed connect.
- A refused request of the Cloudflare API client raises
`SSRFBlockedError`. The exit seam of `new_typer()` (#2502) reports this
`DevOpsCLIError` for each command of the `cloudflare`, `dns`, `tunnel`
and `access` groups. Thus each `devops cloudflare` command prints the
message and exits with code 2, with no traceback.
- The `transport` argument of `CloudflareRadarClient` is deleted. No
caller gave it, and the factory takes no transport.
- The four clients do not use a proxy from `HTTP_PROXY`, `HTTPS_PROXY`
or `ALL_PROXY`, because no factory client does. On a workstation that
gets to the internet only through a proxy, the lookups give the result
of a failed connect, and the `devops cloudflare` commands fail.
- `README.md` names the moved clients. The new capability
`public-api-egress` holds the requirements.

This change is part 3 of the split of #1381. Part 5 (#2437) deletes
`_resolve_host_ips` and `_enforce_non_private_ssrf`. The outcome `ok` of
a failed InternetDB lookup is a separate defect, #2504.

Closes #2430

Change:
`openspec/changes/archive/2026-10-28-2430-public-api-clients-egress-factory/`

---------

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
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.

fix(cli): every command reports a DevOpsCLIError through one exit seam, with its exit status and no traceback

1 participant