fix(cli): detect tar failure in debug --output and set non-zero exit code#1770
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughcreateTarball was exported and changed to return a boolean, inspect the spawned Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI (runDebug)
participant Debug as createTarball
participant Tar as tar (child)
participant Console as Console
CLI->>Debug: createTarball(collectDir, output)
Debug->>Tar: spawnSync tar -czf output -C collectDir .
Tar-->>Debug: exitCode / signal
alt exitCode == 0
Debug-->>CLI: return true
CLI->>Console: print "[debug] Tarball written..." and instructions
else failure (non-zero or signal)
Debug->>Console: error("[debug] Tarball creation failed: ...")
Debug-->>CLI: return false (set process.exitCode = 1)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/lib/debug.ts (1)
435-447: Return a boolean fromcreateTarballso callers can suppress success-style footer text on failure.Right now
createTarballonly mutatesprocess.exitCode;runDebugstill prints completion guidance afterward. Returning an explicit success flag makes the control flow clearer and avoids mixed messaging.Proposed refactor
-export function createTarball(collectDir: string, output: string): void { +export function createTarball(collectDir: string, output: string): boolean { const result = spawnSync("tar", ["czf", output, "-C", dirname(collectDir), basename(collectDir)], { stdio: "inherit", timeout: 60_000, }); if (result.status !== 0 || result.signal) { const reason = result.signal ? `killed by signal ${result.signal}` : `exited with code ${result.status ?? "unknown"}`; error(`Failed to create tarball at ${output} (tar ${reason})`); process.exitCode = 1; - return; + return false; } info(`Tarball written to ${output}`); warn( "Known secrets are auto-redacted, but please review for any remaining sensitive data before sharing.", ); info("Attach this file to your GitHub issue."); + return true; }- if (output) { - createTarball(collectDir, output); - } + const tarOk = output ? createTarball(collectDir, output) : true; console.log(""); - info("Done. If filing a bug, run with --output and attach the tarball to your issue:"); - info(" nemoclaw debug --output /tmp/nemoclaw-debug.tar.gz"); + if (tarOk) { + info("Done. If filing a bug, run with --output and attach the tarball to your issue:"); + info(" nemoclaw debug --output /tmp/nemoclaw-debug.tar.gz"); + } else { + warn("Diagnostics were collected, but tarball creation failed."); + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/lib/debug.ts` around lines 435 - 447, The createTarball function currently only sets process.exitCode on failure; change its signature to return a boolean (true on success, false on failure), keep the existing spawnSync logic and error logging but return false where you set process.exitCode = 1 (and return true at the end on success). Update callers (e.g., runDebug) to capture the boolean result from createTarball and use it to suppress any post-run success/footer messages when false. Ensure the function name createTarball remains and only the return type/returns plus caller checks are modified.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/lib/debug.ts`:
- Around line 435-447: The createTarball function currently only sets
process.exitCode on failure; change its signature to return a boolean (true on
success, false on failure), keep the existing spawnSync logic and error logging
but return false where you set process.exitCode = 1 (and return true at the end
on success). Update callers (e.g., runDebug) to capture the boolean result from
createTarball and use it to suppress any post-run success/footer messages when
false. Ensure the function name createTarball remains and only the return
type/returns plus caller checks are modified.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9a26f6c6-98b9-4013-b666-3e6e1918e76d
📒 Files selected for processing (2)
src/lib/debug.test.tssrc/lib/debug.ts
…code (NVIDIA#1765) `nemoclaw debug --output <invalid-path>` would print 'Tarball written to ...' and exit 0 even when tar failed. Now checks spawnSync return status and signal, reports the error, and sets process.exitCode = 1. Changes: - Check spawnSync result.status and result.signal in createTarball - Report error with red-colored message on failure - Set process.exitCode = 1 so the command exits non-zero - Export createTarball for testability - Add regression tests for both success and failure paths Signed-off-by: kagura-agent <kagura.chen28@gmail.com>
cbb0fa2 to
de1911a
Compare
|
@coderabbitai Good suggestion — updated |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 297756 🏁 Script executed: Length of output: 11156 🏁 Script executed: Length of output: 10021
Looks good to me. Optional nit for later: consider mapping signal termination to a distinct exit code (128 + signal) for parity with uninstall-command, but keeping 1 is perfectly fine since you already include the signal detail in the error. |
|
✨ Thanks for submitting this PR, which proposes a fix for a bug where tarball creation failure is not detected and a non-zero exit code is not set. Possibly related open issues: |
prekshivyas
left a comment
There was a problem hiding this comment.
Good fix — tar failures are now detected and reported correctly. Note: this will conflict with #1775 (already approved) around the same completion message block. Merge #1775 first, then rebase this. @kagura-agent can you rebase onto main after #1775 lands?
Refresh user-facing docs against the 34 commits merged between v0.0.17 and v0.0.18. Highlights: - Replace the Ollama 0.0.0.0 binding guidance with the new authenticated reverse proxy on 127.0.0.1:11435 (#1922). - Document the compatible-endpoint provider defaulting to /v1/chat/completions and the NEMOCLAW_PREFERRED_API=openai-responses opt-in (#1984). - Add the new nemoclaw upgrade-sandboxes command with --check, --auto, and --yes flags (#1943). - Note the cross-sandbox messaging overlap warning and 409 detection in nemoclaw <name> status (#1953). - Document the messaging-token rotation auto-rebuild flow (#1967). - Cover new troubleshooting entries for the Ollama auth proxy, IPv6 localhost resolution, orphan SSH port-forward cleanup on re-onboard, and rotated messaging credentials (#1978, #1950). - Note tar failure exit code for nemoclaw debug --output (#1770) and the orphaned openshell process cleanup in nemoclaw uninstall (#1940). Also: - Extend docs/.docs-skip to exclude the experimental sandbox-mgmt shields and config commands (#1976). - Fix a sphinx-autobuild infinite rebuild loop in docs/conf.py by writing docs/project.json only when its contents change. - Bump the docs version switcher preferred entry to 0.0.18. - Regenerate nemoclaw-user-* agent skills from docs/. Signed-off-by: Miyoung Choi <miyoungc@nvidia.com> Made-with: Cursor
## Summary Refresh user-facing documentation against the 34 commits merged between v0.0.17 and v0.0.18, bump the docs version switcher to v0.0.18, and fix a `sphinx-autobuild` infinite-rebuild loop triggered by `docs/conf.py`. ## Changes - **Ollama authenticated reverse proxy** (#1922): Replace the `0.0.0.0:11434` guidance in `docs/inference/use-local-inference.md` with the new token-gated proxy on `127.0.0.1:11435`, including persisted token, health-check exemption, and sandbox provider wiring. Replace the matching troubleshooting entry in `docs/reference/troubleshooting.md`. - **Compatible-endpoint default API path** (#1984): Document that the compatible-endpoint provider now defaults to `/v1/chat/completions` and update `NEMOCLAW_PREFERRED_API` to describe `openai-responses` as the opt-in instead of `openai-completions`. Updates in `use-local-inference.md`, `switch-inference-providers.md`, and `troubleshooting.md`. - **`nemoclaw upgrade-sandboxes` command** (#1943): Add a new reference entry in `docs/reference/commands.md` covering `--check`, `--auto`, and `--yes` flags. - **Messaging token rotation auto-rebuild** (#1967, #1953): Note the automatic rebuild behavior and cross-sandbox overlap warning in `docs/deployment/set-up-telegram-bridge.md`, `commands.md`, and `troubleshooting.md`. - **Other troubleshooting additions**: - `localhost` → `127.0.0.1` IPv6 note (#1978) - Orphan SSH port-forward cleanup on re-onboard (#1950) - Orphan `openshell` process cleanup in `nemoclaw uninstall` (#1940) - Non-zero exit on tar failure in `nemoclaw debug --output` (#1770) - **Skip list**: Extend `docs/.docs-skip` to exclude the experimental sandbox-mgmt shields and config commands feature (#1976), which was explicitly merged as not-yet-documented. - **Build stability**: `docs/conf.py` now writes `docs/project.json` only when contents change, so `make docs-live` / `sphinx-autobuild` no longer detects its own generated file as a source change and enters an infinite rebuild loop. - **Version switcher**: Bump `docs/versions1.json` and `docs/project.json` preferred entry to v0.0.18 so this refresh renders under the new version. - **Agent skills**: Regenerate `nemoclaw-user-*` skills from `docs/` with `scripts/docs-to-skills.py`. ## Type of Change - [ ] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [x] Doc only (prose changes, no code sample modifications) - [ ] Doc only (includes code sample changes) ## Verification - [x] `npx prek run --all-files` passes (ran via pre-commit hook on staged files) - [ ] `npm test` passes - [ ] Tests added or updated for new or changed behavior - [x] No secrets, API keys, or credentials committed - [x] Docs updated for user-facing behavior changes - [x] `make docs` builds without warnings (doc changes only) - [x] 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) ## AI Disclosure - [x] AI-assisted — tool: Cursor --- Signed-off-by: Miyoung Choi <miyoungc@nvidia.com> Made with [Cursor](https://cursor.com) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * Added `nemoclaw upgrade-sandboxes` command to rebuild sandboxes when base-image digests change. * Introduced authenticated reverse proxy for local Ollama inference with token-based access control. * Automatic sandbox backup, recreation, and restore when messaging credentials are updated. * Cross-sandbox messaging token overlap detection with status warnings. * **Improvements** * Compatible-endpoint provider now defaults to `/v1/chat/completions` API path. * Enhanced troubleshooting documentation with new diagnostics sections. * **Documentation** * Updated onboarding and configuration guides. * Expanded version documentation to 0.0.18. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Miyoung Choi <miyoungc@nvidia.com>
Problem
nemoclaw debug --output /nonexistent/path/debug.tar.gzprints "Tarball written to ..." and exits with code 0 even when tar fails. Users see a success message despite no tarball being created.Fixes #1765
Root Cause
createTarball()calledspawnSync("tar", ...)without checking the return status. The success message was unconditionally printed.Fix
spawnSyncresult.statusand.signalprocess.exitCode = 1Testing
createTarball:process.exitCode === 1npx vitest run src/lib/debug.test.ts— 10/10)tscclean,eslintclean,prettiercleanSigned-off-by: kagura-agent kagura.chen28@gmail.com
Summary by CodeRabbit
Bug Fixes
Tests