fix(sandbox): catch McpBridgeError in destroy MCP bridge path (#8103) - #8298
fix(sandbox): catch McpBridgeError in destroy MCP bridge path (#8103)#8298yanyunl1991 wants to merge 4 commits into
Conversation
…ze in destroy path (#8103) `executeSandboxDestroy` called `prepareMcpDestroy` and `finalizeMcpDestroy` with no `McpBridgeError` guard. When a managed MCP server is present and the gateway becomes unreachable, `inspectExactMcpDestroyProvider` throws `McpBridgeError("Could not inspect OpenShell provider…")` which propagated uncaught, crashing `destroy --yes` with a stack trace instead of a clean exit-1 message. The same uncaught escape existed for `finalizeMcpDestroy`'s internal re-throw after post-delete cleanup fails. Both call sites now catch `McpBridgeError` and return `{ ok: false, … }`, letting the existing failure-path rendering in `destroy.ts` surface the error cleanly and exit with the error's own `exitCode`. Signed-off-by: yanyunl1991 <yanyunl@nvidia.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughChangesSandbox destroy MCP errors
Architecture budget updates
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Code Coverage OverviewLanguages: TypeScript TypeScript / code-coverage/pluginThe overall coverage in commit 331c168 in the TypeScript / code-coverage/cliThe overall coverage in commit 331c168 in the Show a code coverage summary of the most impacted files.
Updated |
PR Review Advisor — No blocking findings reportedAdvisor assessment: No blocking advisor findings reported Model lanes
Second-opinion terminology and E2E selections are advisory. They do not change the primary assessment or E2E / PR Gate. 1 semantic terminology decisionTerminology decisions are advisory. They affect the assessment only when a separate finding identifies concrete semantic impact.
E2E guidanceAdvisory only. E2E / PR Gate selects and runs jobs independently. Recommended E2E: 2 optional E2E recommendations
This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge. |
|
Security review: PASS — no findings Reviewed revision
The remaining failed Nemotron advisor lane is a model-protocol failure after a partial second-opinion review. The primary advisor completed with high confidence and published |
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Security review — PASSReviewed revision No security findings were identified.
Validation:
|
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
|
Compliance hold: do not merge this PR. Commit |
|
Replacement: #8313 Evidence that #8313 supersedes this PR:
This PR cannot satisfy the commit-verification gate because its published history contains an unverified commit. #8313 now owns the remaining CI and review work. Closing this PR as superseded avoids duplicate review and merge activity. |
|
Replacement: #8324. It preserves the original verified contributor commit and effective destroy fix, refreshes onto current protected main, and uses only GitHub-verified commits. This closed PR remains unsuitable for merge because its published history contains an unverified maintenance commit. |
…#8313) <!-- markdownlint-disable MD041 --> ## Summary This replacement preserves the implementation and contributor attribution from #8298 while removing an unverified commit from the published history. Sandbox destruction now returns a structured, redacted failure when MCP bridge preparation or finalization fails instead of exposing an uncaught stack trace. ## Related Issue Refs #8103 Supersedes #8298 after this replacement passes all repository gates. ## Changes - Catch `McpBridgeError` before destructive work starts and return its redacted failure result. - Catch `McpBridgeError` after sandbox deletion and preserve the registry state required for retry. - Rethrow other error types and add negative-path tests for both MCP bridge failure stages. - Preserve Yanyun Liao as the implementation author and Carlos Villela as the architecture-budget update author. - Ratchet the affected source architecture budgets to the values measured by the replacement branch. ## Type of Change - [x] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [ ] Doc only (includes code sample changes) ## Quality Gates - [x] Tests added or updated for changed behavior - [ ] Existing tests cover changed behavior — justification: - [ ] Tests not applicable — justification: - [ ] Docs updated for user-facing behavior changes - [x] Docs not applicable — justification: Existing sandbox lifecycle documentation covers MCP preparation failures, retry-state preservation, post-deletion cleanup, and rerunning destroy. This change returns the documented structured failure instead of an uncaught stack trace. - [x] Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging) - [x] Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: The nine-category maintainer security review passed with no findings: #8313 (comment) - [ ] Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue: ## Documentation Writer Review - [x] Documentation writer subagent reviewed the completed changes - Result: `no-docs-needed` - Evidence: `docs/security/best-practices.mdx` already defines the CLI redaction contract, and `docs/manage-sandboxes/manage-mcp-servers.mdx` already documents preserved recovery state and rerunning `destroy`. The change adds no command, option, configuration, lifecycle boundary, or supported user procedure. - Agent: Codex Desktop <!-- docs-review-head-sha: ec94feb --> <!-- docs-review-agents-blob-sha: 3dd7c24 --> ## DGX Station Hardware Evidence - [ ] Tested on DGX Station - Tested commit: Not applicable; `scripts/prepare-dgx-station-host.sh` is unchanged. - Station profile/scenario: Not applicable. - Result: Not applicable. - Supporting evidence: Not applicable. ## Verification - [x] PR description includes a `Signed-off-by:` line and every commit appears as `Verified` in GitHub - [x] Normal `pre-commit`, `commit-msg`, and `pre-push` hooks passed, or `npm run validate:pr` passed after refreshing `origin/main` when hooks were skipped or unavailable - [x] Targeted behavior tests pass for the current change set, or tests are marked not applicable above — `npx vitest run --project cli src/lib/actions/sandbox/destroy-flow.test.ts` passed 27 tests. - [x] Applicable broad gate passed — `npm run typecheck:cli`, `npm run source-shape:check`, and `npx prek run --from-ref origin/main --to-ref HEAD` passed. - [x] Quality Gates section completed with required justifications or waivers - [x] No secrets, API keys, or credentials committed - [ ] `npm run docs` builds without warnings (doc changes only) - [ ] Doc pages follow the [style guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) - [ ] New doc pages include SPDX header and frontmatter (new pages only) --- Signed-off-by: yanyunl1991 <mzhong@nvidia.com> Signed-off-by: Yanyun Liao <yanyunl@nvidia.com> Signed-off-by: Carlos Villela <cvillela@nvidia.com> Signed-off-by: Apurv Kumaria <akumaria@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Sandbox destruction now handles MCP bridge failures gracefully instead of exposing unhandled errors. * Preparation failures stop deletion and cleanup safely. * Finalization failures return clear failure results, redact sensitive details, and preserve required sandbox and gateway state. * Retrying after a finalization failure now completes cleanup successfully. * **Tests** * Added coverage for MCP bridge failures during sandbox destruction, including exit codes, redaction, retries, and state preservation. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: yanyunl1991 <yanyunl@nvidia.com> Signed-off-by: Apurv Kumaria <akumaria@nvidia.com> Signed-off-by: Carlos Villela <cvillela@nvidia.com> Co-authored-by: Yanyun Liao <yanyunl@nvidia.com> Co-authored-by: Carlos Villela <cv@lixo.org>
Summary
Sandbox destruction now returns the existing structured MCP bridge error when bridge preparation or finalization fails. Before this change, the command exposed an uncaught stack trace. This PR repairs the destroy recovery path; #8103 continues to track the separate rebuild authority-drift failure.
Related Issue
Refs #8103
Changes
McpBridgeErrorbefore destructive work starts and return its redacted failure result.McpBridgeErrorafter sandbox deletion and preserve the retry state.Type of Change
Quality Gates
Documentation Writer Review
no-docs-neededdocs/manage-sandboxes/manage-mcp-servers.mdxalready covers MCP preparation, recovery-state preservation, post-deletion cleanup, and rerunning destroy.docs/reference/commands.mdxalready covers unreachable gateways and managed MCP ownership. The change adds no command, option, workflow, lifecycle outcome, or recovery action.DGX Station Hardware Evidence
scripts/prepare-dgx-station-host.shis unchanged.Verification
Signed-off-by:line and every commit appears asVerifiedin GitHubpre-commit,commit-msg, andpre-pushhooks passed, ornpm run validate:prpassed after refreshingorigin/mainwhen hooks were skipped or unavailablenpx vitest run --project cli src/lib/actions/sandbox/destroy-flow.test.tspassed 27 tests.0b1eeb726.npm run docsbuilds without warnings (doc changes only)Signed-off-by: yanyunl1991 mzhong@nvidia.com
Summary by CodeRabbit
Bug Fixes
Tests