Skip to content

refactor: reach block-bodied-closure error messages, and clarify the fix hint#3613

Merged
chet merged 1 commit into
NVIDIA:mainfrom
chet:gh-issue-3468-03
Jul 16, 2026
Merged

refactor: reach block-bodied-closure error messages, and clarify the fix hint#3613
chet merged 1 commit into
NVIDIA:mainfrom
chet:gh-issue-3468-03

Conversation

@chet

@chet chet commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

A small follow-up to #3595. That PR reached format! inside expression-bodied closures (.wrap_err_with(|| format!(...))); this closes the sibling gap for block-bodied closures (.wrap_err_with(|| { format!(...) })) — the exact form CodeRabbit flagged there — and makes the checker's failure output easy for a contributor to act on.

  • leading_str_lit gains an Expr::Block arm (forward to the block's tail expression), so || { format!(...) } is reached just like || format!(...). --fix lowercased 19 messages across 5 files (agent file-ops, k8s_pod_handler, hbn, machine-controller scout scripts, and the xtask workspace-deps check).
  • The report-mode failure now prints the rule, the exact cargo xtask lint-error-messages --fix command on its own line, and the // xtask:allow-error-case opt-out for a deliberate capital — instead of a one sentence tacked onto the violation count.

Still deferred, and documented in the checker TODO: struct-literal error fields (CarbideError::Internal { message: "..." }, ~150 sites), manual Display/write! bodies, and macro-body-nested sites.

Continues #3595 · supports #3468

@chet
chet requested a review from a team as a code owner July 16, 2026 17:55
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 137b9e0d-f88d-47d2-b7fd-3e1433c51ae8

📥 Commits

Reviewing files that changed from the base of the PR and between e28da7c and 3089d35.

📒 Files selected for processing (6)
  • crates/agent/src/agent_platform.rs
  • crates/agent/src/extension_services/k8s_pod_handler.rs
  • crates/agent/src/hbn.rs
  • crates/machine-controller/src/scout_firmware_scripts.rs
  • crates/xtask/src/error_message_case.rs
  • crates/xtask/src/workspace_deps.rs
🚧 Files skipped from review as they are similar to previous changes (6)
  • crates/xtask/src/workspace_deps.rs
  • crates/agent/src/hbn.rs
  • crates/agent/src/extension_services/k8s_pod_handler.rs
  • crates/machine-controller/src/scout_firmware_scripts.rs
  • crates/agent/src/agent_platform.rs
  • crates/xtask/src/error_message_case.rs

Summary by CodeRabbit

  • Bug Fixes

    • Standardized capitalization and wording of error-message text in runtime file updates, Kubernetes pod-spec handling, container-shell execution, Scout firmware script resolution, and workspace dependency version parsing.
  • Tests

    • Added an end-to-end test to confirm error-message rewrites are detected inside block-bodied closures, while existing coverage continues to ensure unrelated format! cases remain unchanged.
  • Documentation / Tooling

    • Refined lint output and guidance, including clearer auto-fix instructions and updated behavior notes for how message patterns are detected.

Walkthrough

The pull request standardizes capitalization in error contexts across agent and controller code. It also extends the error-message casing linter to process block-bodied closures, improves violation guidance, and adds end-to-end coverage.

Changes

Error message standardization

Layer / File(s) Summary
Block-bodied closure linting
crates/xtask/src/error_message_case.rs
The linter locates formatted messages inside block-bodied closures, reports expanded remediation guidance, and verifies rewriting through an end-to-end test.
Runtime error context casing
crates/agent/src/agent_platform.rs, crates/agent/src/extension_services/k8s_pod_handler.rs, crates/agent/src/hbn.rs
Agent file operations, pod-spec handling, and container execution update error-message capitalization without changing control flow.
Controller and dependency context casing
crates/machine-controller/src/scout_firmware_scripts.rs, crates/xtask/src/workspace_deps.rs
Scout firmware and dependency-version parsing contexts change to the standardized lowercase wording.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: handling block-bodied closures and improving the fix hint.
Description check ✅ Passed The description is clearly related to the changeset and explains the checker fix and reporting updates.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/machine-controller/src/scout_firmware_scripts.rs`:
- Around line 257-262: Update the expected error string in
errors_for_zero_timeout_metadata to use lowercase “scout,” matching the
normalized message emitted by read_metadata. Keep the rest of the assertion
unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 12dcb74b-ca56-4b43-95f6-888566f357eb

📥 Commits

Reviewing files that changed from the base of the PR and between 3fd5648 and e28da7c.

📒 Files selected for processing (6)
  • crates/agent/src/agent_platform.rs
  • crates/agent/src/extension_services/k8s_pod_handler.rs
  • crates/agent/src/hbn.rs
  • crates/machine-controller/src/scout_firmware_scripts.rs
  • crates/xtask/src/error_message_case.rs
  • crates/xtask/src/workspace_deps.rs

Comment thread crates/machine-controller/src/scout_firmware_scripts.rs
…fix hint

NVIDIA#3595 taught the `lint-error-messages` checker to peel a `format!` inside an expression-bodied closure (`.wrap_err_with(|| format!(...))`), but the common *block*-bodied form (`.wrap_err_with(|| { format!(...) })`) still slipped through -- the exact siblings CodeRabbit pointed at on NVIDIA#3595. This closes that gap, and while we're in the failure path, makes the "how do I fix this?" output impossible to miss for a contributor who trips the check.

Primary callouts are:

- `leading_str_lit` gains an `Expr::Block` arm that forwards to the block's tail expression, so a message behind `|| { format!(...) }` is reached just like the expression-bodied form. `--fix` then lowercased 19 messages across 5 files (agent file-ops, `k8s_pod_handler`, `hbn`, machine-controller scout scripts, and the xtask workspace-deps check).
- The report-mode failure now prints the rule, the exact `cargo xtask lint-error-messages --fix` command on its own line, and the `// xtask:allow-error-case` opt-out for a deliberate capital -- instead of a single sentence tacked onto the violation count.

Still out of reach, and marked in the checker `TODO` as the remaining follow-up: struct-literal error fields (`CarbideError::Internal { message: "..." }`, ~150 sites), manual `impl Display`/`write!` bodies, and macro-body-nested sites.

Tests added! -- `end_to_end_rewrite_reaches_block_closure` drives the real span -> byte-range -> splice path through a `.wrap_err_with(|| { format!(...) })` and checks the `{host}` interpolation survives.

This continues NVIDIA#3595 and supports NVIDIA#3468

Signed-off-by: Chet Nichols III <chetn@nvidia.com>
@chet
chet force-pushed the gh-issue-3468-03 branch from e28da7c to 3089d35 Compare July 16, 2026 18:54
@github-actions

Copy link
Copy Markdown

🔍 Container Scan Summary

Service Total Critical High Medium Low Other
boot-artifacts-aarch64 3 0 0 3 0 0
boot-artifacts-x86_64 3 0 0 3 0 0
forge-admin-cli-x86_64 259 16 29 79 7 128
machine-validation-runner 532 39 113 184 15 181
machine_validation 532 39 113 184 15 181
machine_validation-aarch64 532 39 113 184 15 181
nvmetal-carbide 532 39 113 184 15 181
TOTAL 2393 172 481 821 67 852

Per-CVE detail lives in the per-service grype-* artifacts (JSON + SARIF). Severity counts only — no CVE IDs published here.

@chet
chet merged commit d5b6ff9 into NVIDIA:main Jul 16, 2026
59 checks passed
@chet
chet deleted the gh-issue-3468-03 branch July 16, 2026 20:41
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.

2 participants