Skip to content

Separate operation context from exit-status classification - #21587

Merged
zanieb merged 1 commit into
zb/python-upgrade-error-hintsfrom
zb/operation-error-context
Sep 11, 2026
Merged

zanieb merged 1 commit into
zb/python-upgrade-error-hintsfrom
zb/operation-error-context

Conversation

@zanieb

@zanieb zanieb commented Sep 10, 2026

Copy link
Copy Markdown
Member

Resolution headings are assembled inside UvError::from_operation, mixing operation-specific formatting with exit-status selection. Store no-solution and contextual-requirement headings as typed operations::Error variants, and attach command context before converting to UvError. Add the default no-solution heading only at the final command-error boundary so errors nested under higher-level build or tool messages do not gain redundant headings. The original sources and hints remain available, and diagnostic output and exit-status policy are unchanged.

Prior work:

@zanieb
zanieb added this pull request to stack #21585 September 10, 2026 15:34
@zanieb
zanieb removed this pull request from stack #21585 September 10, 2026 15:42
@zanieb
zanieb added this pull request to stack #21588 September 10, 2026 15:43
@zanieb zanieb added the internal A refactor or improvement that is not user-facing label Sep 10, 2026
@zanieb
zanieb force-pushed the zb/operation-error-context branch from 3b24857 to 99fb143 Compare September 10, 2026 20:11
@zanieb
zanieb force-pushed the zb/operation-error-context branch from 99fb143 to 05716e9 Compare September 10, 2026 21:51
@zanieb
zanieb marked this pull request as ready for review September 10, 2026 21:53
@zanieb
zanieb force-pushed the zb/operation-error-context branch from 05716e9 to ed7b664 Compare September 10, 2026 22:18
@zanieb
zanieb deployed to automations September 10, 2026 22:51 — with GitHub Actions Active
@zanieb
zanieb force-pushed the zb/operation-error-context branch from ed7b664 to d12e43b Compare September 11, 2026 18:12
@zanieb
zanieb deployed to automations September 11, 2026 18:14 — with GitHub Actions Active
@zanieb
zanieb merged commit fd65032 into main Sep 11, 2026
80 of 86 checks passed
@zanieb
zanieb deleted the zb/operation-error-context branch September 11, 2026 18:37
zanieb added a commit that referenced this pull request Sep 11, 2026
Route the remaining package-operation errors through `UvError` and the
standard error-chain renderer, then remove uv's direct `miette`
dependency and global hook. Diagnostics use the same source-chain
formatting and hint collection as other commands, with cause-specific
hints before general command advice. No-solution headings omit trailing
punctuation, retain their command context, and are not repeated inside
build-dependency errors. Final errors remain visible with `-q` and are
suppressed with `-qq`.

Classify operation failures by their underlying cause instead of by
which renderer handles them. Each error type owns its classification,
and type-erased build errors forward it. Expected package, resolution,
build, integrity, and lock-validation failures use code 1, while
recognized transport, cache, filesystem, and internal failures use code
2. This deliberately changes some previously inconsistent statuses
without attempting to normalize every standalone command or opaque
archive-error path. Command-line argument errors remain code 2.
Third-party dependencies may still use `miette` internally.

Prior work:

- #14546 removed `miette` from `uv venv`.
- #17535 added first-party line wrapping.
- #18090 established the `Hint` and `Hints` APIs.
- #20155 made hints explicit in error-chain rendering.
- #20156 preserved indentation in multiline causes.
- #20159 migrated `uv build` errors to standard rendering.
- #20160 migrated tool requirement errors to standard rendering.
- #20188 introduced the explicit `UvError` model.
- #20163 routed final errors through `Printer` for `-q` and `-qq`.
- #20217 enabled cause-chain rendering for user errors.
- #21563 added verification of index-provided metadata hashes.
- #21279 reused URL-provided hashes during resolution.
- #21584 renamed the hint-producing trait to `Hinted`.
- #21577 added explicit hint ordering.

Follow-up work:

- #21566 collects hints for batched `uv tool upgrade` failures and fixes
their quiet-mode output.
- #21568 routes Python upgrade request errors and version-file hints
through `UvError`.
- #21587 separates operation-specific diagnostic context from
exit-status classification.
- #21599 renders error and warning causes with compact tree connectors.
zanieb added a commit that referenced this pull request Sep 11, 2026
Render error and warning source chains with compact `├──` and `└──` tree
connectors instead of repeating `Caused by:`. The shared formatter
retains the `error:` and `warning:` labels, aligns wrapped and authored
multiline causes beneath their text, and includes the gutter in the
terminal-width calculation. Hint placement and exit-status
classification are unchanged.

```text
error: Failed to download and build `demo-pkg @ http://[LOCALHOST]/files/demo_pkg-1.0.0.tar.gz`
  ├── Failed to extract archive: demo-pkg @ http://[LOCALHOST]/files/demo_pkg-1.0.0.tar.gz
  ├── I/O operation failed during extraction
  └── Invalid gzip header
```

Prior work:

- #17110 routes the remaining package-operation errors through the
shared formatter.
- #21587 separates operation-specific diagnostic context from
exit-status classification.
zanieb added a commit that referenced this pull request Sep 11, 2026
Render each source error with a compact `cause:` label, keeping the
existing `error:` and `warning:` headings. Wrapped and authored
continuation lines align beneath the cause text, and hints remain
separate from the error chain. This changes presentation only; source
ordering and exit statuses are unchanged.

Prior work:

- #17110 removes the direct `miette` dependency and routes command
failures through the shared renderer.
- #21587 separates operation context from exit-status classification.
- #21599 introduces compact tree connectors for source chains.

This branch was successfully deployed

1 active deployment
automations — d12e43b8 Deployed Sep 11, 2026 by zanieb via review / security review #46440
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal A refactor or improvement that is not user-facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants