Repository navigation
feat(command): let handlers attach warnings to the result envelope - #131
Open
jpage-godaddy wants to merge 1 commit into
Open
jpage-godaddy wants to merge 1 commit into
jpage-godaddy wants to merge 1 commit into
Conversation
The envelope already had a `warnings` field, but nothing populated it and a handler could not reach it. Add `CommandResult::with_warning`, carry the messages through middleware onto the success envelope, and render them as a "Warnings:" block in human output (JSON and TOON already serialize them). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
jpage-godaddy
requested review from
axburgess-godaddy,
mguerrero3-godaddy,
qcai-godaddy,
rts1-godaddy and
runruh-godaddy
as code owners
October 21, 2026 22:22
There was a problem hiding this comment.
🟢 Approval recommended
Static review identified no blocking issues in the additive API, warning propagation, rendering, or supplied tests; tests were not executed during this review.
No open issues 🎉
What changed in this PR
Adds handler-supplied, non-fatal warnings to the existing result envelope, allowing successful commands to report partial results or other caveats.
Changes:
- Adds
CommandResult::with_warningand propagates warnings through middleware. - Displays warnings before “Next steps” in human output, including custom views.
- Documents the API and adds integration and renderer tests.
| File | Description |
|---|---|
| cli-engine/tests/warnings.rs | Tests warning ordering, output formats, and omission when empty. |
| cli-engine/src/output/human/tests/footer.rs | Tests warning placement and absence when empty. |
| cli-engine/src/output/human/mod.rs | Integrates warnings into standard and custom human rendering. |
| cli-engine/src/output/human/footer.rs | Adds the warnings block formatter. |
| cli-engine/src/middleware/run.rs | Copies result warnings into the success envelope. |
| cli-engine/src/command/mod.rs | Adds the warning builder method and metadata field. |
| cli-engine/docs/concepts.md | Documents handler warnings with an example. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CommandResult::with_warning(msg)so a handler that succeeds can still surface non-fatal warnings. The envelope already had awarningsfield andEnvelope::add_warning, butCommandResulthad no way to reach them.warningsis omitted when empty.warnings. It now prints aWarnings:block ahead ofNext steps:, including for commands with a custom human view.CommandResultMetadatais#[non_exhaustive], so the new field is not a breaking change.Known limits
raw_outputcommands render only the verbatim string, so warnings appear in the envelope but not in the printed text.CommandResultand are unchanged.Test plan
tests/warnings.rs: end-to-end throughCli::runfor JSON (ordering), TOON, human, and absence when no warningsNext steps:, no block when empty)-D warnings, rustdoc-D warnings,cargo test --all-targets,cargo test --doc, module-size check, missing-docs count is zero🤖 Generated with Claude Code