Skip to content

feat: add nemoclaw debug command for collecting diagnostics - #502

Merged
kjw3 merged 4 commits into
NVIDIA:mainfrom
cv:cv/nemoclaw-debug
Mar 21, 2026
Merged

kjw3 merged 4 commits into
NVIDIA:mainfrom
cv:cv/nemoclaw-debug

Conversation

@cv

@cv cv commented Mar 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add nemoclaw debug CLI command and standalone scripts/debug.sh that collects system, GPU, Docker, OpenShell, and network diagnostics for bug reports
  • Supports --quick for minimal diagnostics and --output to save a tarball for GitHub issues
  • Updates the bug report issue template to prompt users for debug output

Related Issue

Closes #500

Changes

  • scripts/debug.sh — New standalone bash script collecting diagnostics across system, processes, GPU, Docker, OpenShell, network, and kernel categories. Gracefully skips unavailable commands.
  • bin/nemoclaw.js — Register debug as a global command, delegate to the bash script with the default sandbox name, add "Troubleshooting" section to help text.
  • .github/ISSUE_TEMPLATE/bug_report.yml — Add "Debug Output" field prompting users to attach nemoclaw debug output.
  • test/cli.test.js — Add tests for debug --help and help text mentioning the debug command.

Type of Change

  • Code change for a new feature, bug fix, or refactor.

Testing

  • npm test passes (new tests + all existing CLI tests green).
  • nemoclaw debug --help shows usage and exits 0.

Checklist

  • I have read and followed the contributing guide.
  • Tests added or updated.
  • No secrets, API keys, or credentials committed.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a diagnostic "debug" command to collect troubleshooting info, with a quick mode and an option to export results to a tarball; Help now includes a Troubleshooting section.
  • Tests

    • Added CLI tests for debug (help, quick mode, invalid option) and updated top-level help assertions to reference Troubleshooting/debug.
  • Chores

    • Updated bug report template to prompt for debug output or a quick debug paste.

Add a debug command that collects system, GPU, Docker, OpenShell, and
network diagnostics to help triage bug reports. Supports --quick for a
minimal subset and --output to produce a tarball for GitHub issues.

Also updates the bug report issue template to prompt users for debug
output.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Mar 20, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 816b009c-6f53-42d6-bfb3-25d40186b830

📥 Commits

Reviewing files that changed from the base of the PR and between 1bd8d36 and 1851ad7.

📒 Files selected for processing (2)
  • scripts/debug.sh
  • test/cli.test.js
✅ Files skipped from review due to trivial changes (1)
  • scripts/debug.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/cli.test.js

📝 Walkthrough

Walkthrough

Adds a new nemoclaw debug CLI command and a standalone scripts/debug.sh diagnostic collector, updates CLI help and tests, and augments the GitHub bug report template to request debug output or quick output.

Changes

Cohort / File(s) Summary
CLI Command
bin/nemoclaw.js
Add debug(args) handler, dispatch debug command, spawn scripts/debug.sh with env SANDBOX_NAME, and add a Troubleshooting section to help() documenting nemoclaw debug [--quick] and --output.
Diagnostic Script
scripts/debug.sh
New executable Bash script that collects system, process, GPU, Docker, OpenShell, network, and kernel diagnostics; supports --quick, --sandbox, --output/-o; timeouts, redaction, writes to temp dir and optionally produces a gzip tarball.
Tests
test/cli.test.js
Add tests asserting debug --help and debug --quick behavior and output markers; add a negative test for unknown option and assert top-level help includes Troubleshooting referencing nemoclaw debug.
Issue Template
.github/ISSUE_TEMPLATE/bug_report.yml
Add optional debug-output textarea asking for nemoclaw debug --output /tmp/nemoclaw-debug.tar.gz or nemoclaw debug --quick; clarify logs field to include additional logs not covered by debug output.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant User
    participant CLI as "nemoclaw CLI"
    participant Script as "scripts/debug.sh"
    participant Docker as "Docker / Containers"
    participant GPU as "NVIDIA / GPU"
    participant FS as "Filesystem / Tarball"

    User->>CLI: run `nemoclaw debug [--quick] [--output FILE]`
    CLI->>Script: spawn `scripts/debug.sh` with args + env SANDBOX_NAME
    Script->>Docker: collect docker ps/logs/inspect (if available)
    Script->>GPU: run nvidia-smi (if available)
    Script->>FS: write collected files to temp dir
    alt --output specified
        Script->>FS: create gzip tarball at FILE
        Script-->>CLI: print tarball path and summary
    else
        Script-->>CLI: stream collected output to stdout and remove temp dir
    end
    CLI-->>User: exit with script's exit code and output
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through logs and kernel sighs,
Collected clues beneath the skies,
A tarball bundle, neat and quick,
Secrets redacted, output slick,
Hooray — the debug hop was slick! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a nemoclaw debug command for collecting diagnostics, which is the primary objective of the pull request.
Linked Issues check ✅ Passed The code changes comprehensively address all coding requirements from issue #500: the CLI command is implemented, the bash script collects all required diagnostic categories, --quick mode is supported, --output tarball is supported, and help/template updates are included.
Out of Scope Changes check ✅ Passed All changes align with issue #500 objectives: CLI command integration, diagnostic script implementation, minimal mode support, tarball output, issue template updates, and test coverage for the debug command.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@kjw3 kjw3 self-assigned this Mar 20, 2026

@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: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@scripts/debug.sh`:
- Line 214: The current pipeline pipes collect's stdout into tail, so the
archived dmesg.txt still contains the full dmesg output; change the invocation
so collect receives the truncated output instead (e.g., run collect "dmesg" with
a shell command that executes dmesg | tail -100 so the collector archives only
the last 100 lines). Update the command around the existing collect "dmesg"
invocation to invoke a shell (-c) that runs dmesg | tail -100 so the saved
diagnostics reflect the intended truncation.
- Around line 218-234: Add an explicit sensitive-data warning before prompting
users to attach the tarball: when OUTPUT is set and right after the info
"Tarball written to ${OUTPUT}" (and similarly before the final guidance lines
that show the --output example), call the info logger to print a short warning
about potentially sensitive information in the archive (e.g., "Warning: this
tarball may contain sensitive data — review and redact logs/configs before
uploading."). Use the existing info function and the variables OUTPUT and
COLLECT_DIR to provide context, and ensure the warning appears both immediately
after writing the tarball and before the final "Done..."/usage lines.
- Around line 101-106: Add a runtime check for the presence of a timeout binary
and use it only when available: detect "timeout" or "gtimeout" once at script
start (set a TIMEOUT_CMD variable to the found command or empty), then replace
the direct call to timeout 30 "$@" > "$outfile" 2>&1 in the block using
"$outfile" with a conditional invocation that uses "$TIMEOUT_CMD" when non-empty
and falls back to running the command without any timeout when empty; ensure the
detection runs early (before the timeout invocation) and export or use the
TIMEOUT_CMD variable in the scope where the timeout is called.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7f7510c8-e5dd-4104-ad63-4b730c96dfb8

📥 Commits

Reviewing files that changed from the base of the PR and between 3aaef13 and d4ab1d7.

📒 Files selected for processing (4)
  • .github/ISSUE_TEMPLATE/bug_report.yml
  • bin/nemoclaw.js
  • scripts/debug.sh
  • test/cli.test.js

Comment thread scripts/debug.sh Resolved
Comment thread scripts/debug.sh Resolved
Comment thread scripts/debug.sh Resolved
kjw3

This comment was marked as outdated.

@kjw3
kjw3 self-requested a review March 20, 2026 19:15
- Add timeout/gtimeout detection for macOS compatibility
- Wrap piped commands in sh -c so collect() captures full pipeline
- Add sensitive data warning before tarball attachment prompt

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@cv

cv commented Mar 20, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review again?

@coderabbitai

coderabbitai Bot commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

@cv Sure! I'll kick off a fresh review of this PR right away.

✅ Actions performed

Full review triggered.

@ericksoa

Copy link
Copy Markdown
Member

Review comments:

  1. Potential information leakage — ps -ef, docker inspect, lsof -i -P -n, and /etc/resolv.conf can expose secrets (env vars, API keys in command args, internal network topology). Wouldn't it be worth either redacting known sensitive patterns or at minimum printing a warning that the output may contain sensitive info before users paste it into a public issue?

  2. dmesg piping issue — collect "dmesg" dmesg | tail -100 pipes through tail outside the collect function, so collect captures the full dmesg output (and the tail -100 only affects stdout). Same issue with ps ... | head -30. Shouldn't the truncation happen inside collect, or be passed as part of the command?

  3. Linux-specific commands without platform check — free -m, ss -ltnp, ip addr, vmstat, iostat, lsof, ps -eo ... --sort are GNU/Linux-specific. The curl-pipe-bash example suggests this could run on macOS too. Would it help to either detect the platform or document this as Linux-only?

  4. curl ... | bash example won't work with flags — The help text advertises curl -fsSL ... | bash but piped scripts can't receive --quick/--output args. Would this need bash -s -- --quick syntax, or should the example be removed/updated?

  5. Unknown options silently skipped — warn "Unknown option: $1" and continue means misspelled flags like --quik are silently ignored. Would exiting non-zero on unknown options be safer?

  6. Tests only cover --help — Could a test run debug --quick in a controlled env and verify it exits 0 and produces some output, even if most collectors skip due to missing 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

🧹 Nitpick comments (1)
scripts/debug.sh (1)

74-77: Unknown flags should fail fast, not continue.

At Line 75, the script only warns and proceeds. A typo like --ouptut can silently produce the wrong artifact/behavior while still exiting successfully.

Suggested change
     *)
-      warn "Unknown option: $1"
-      shift
+      fail "Unknown option: $1 (run --help for usage)"
       ;;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/debug.sh` around lines 74 - 77, The default case in the
option-parsing switch currently calls warn "Unknown option: $1" and shift which
allows the script to continue on unknown flags; change the default handler so
unknown options cause an immediate non-zero exit (e.g., call the script's
error/fatal function or invoke exit with a non-zero code) instead of shifting
and continuing; update the block that references warn and shift to log the
unknown option and then exit (or call any existing usage()/fatal() helper) to
fail fast.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@scripts/debug.sh`:
- Around line 191-199: The OpenShell section collects metadata but misses
in-sandbox diagnostics; update the block that uses SANDBOX_NAME (and respects
QUICK) to exec into the sandbox (via the same mechanism used by openshell
sandbox get/logs) and run/collect process and memory snapshots (e.g., ps aux,
top -b -n1, /proc/meminfo, free -h), open file lists (lsof), and short
dmesg/syslog excerpts, storing each as distinct collect entries like
"openshell-sandbox-ps", "openshell-sandbox-top", "openshell-sandbox-meminfo",
"openshell-sandbox-lsof", etc.; ensure these new collect calls run only when
SANDBOX_NAME is set and QUICK=false and reuse the existing collect wrapper so
outputs integrate with the rest of the debug bundle.

---

Nitpick comments:
In `@scripts/debug.sh`:
- Around line 74-77: The default case in the option-parsing switch currently
calls warn "Unknown option: $1" and shift which allows the script to continue on
unknown flags; change the default handler so unknown options cause an immediate
non-zero exit (e.g., call the script's error/fatal function or invoke exit with
a non-zero code) instead of shifting and continuing; update the block that
references warn and shift to log the unknown option and then exit (or call any
existing usage()/fatal() helper) to fail fast.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8ccf8d94-4931-453e-a26a-7984bd2bfa24

📥 Commits

Reviewing files that changed from the base of the PR and between 3aaef13 and 2f6dae2.

📒 Files selected for processing (4)
  • .github/ISSUE_TEMPLATE/bug_report.yml
  • bin/nemoclaw.js
  • scripts/debug.sh
  • test/cli.test.js

Comment thread scripts/debug.sh Resolved
Runs ps, free, top, and gateway log collection inside the sandbox when
it is reachable, addressing the full diagnostic scope from issue #500.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@kjw3 kjw3 assigned ericksoa and unassigned kjw3 Mar 20, 2026
@kjw3
kjw3 dismissed their stale review March 20, 2026 19:30

Was a test of permissions

@kjw3
kjw3 requested review from ericksoa and removed request for kjw3 March 20, 2026 19:30
- Redact known sensitive patterns (API keys, tokens, passwords) from all
  collected output before saving to files or tarball
- Exit non-zero on unknown options instead of silently skipping
- Fix curl|bash example to use `bash -s -- --quick` syntax
- Add tests for `debug --quick` (runs collectors, exits 0) and unknown
  option rejection

Linux-specific commands (free, ss, vmstat, etc.) are already handled
gracefully by collect() which skips missing commands.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@wscurran wscurran added priority: high enhancement New capability or improvement request labels Mar 20, 2026
@wscurran

Copy link
Copy Markdown
Contributor

Thanks for adding this debug command, it will make it easier for users to collect and share diagnostics information when reporting issues.

1 similar comment
@wscurran

Copy link
Copy Markdown
Contributor

Thanks for adding this debug command, it will make it easier for users to collect and share diagnostics information when reporting issues.

@cv

cv commented Mar 21, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the feedback! All addressed in 1851ad7 — added sensitive data warning, fixed dmesg piping inside collect, and made unknown flags fail fast. Ready for re-review!

@kjw3 kjw3 assigned kjw3 and unassigned ericksoa Mar 21, 2026
@kjw3

kjw3 commented Mar 21, 2026

Copy link
Copy Markdown
Contributor

Thanks for following through on the review feedback.

I re-reviewed the latest tip and the remaining blockers are resolved:

  • unknown flags now fail fast
  • the standalone curl example now shows how to pass flags
  • known secret patterns are redacted before output is saved
  • the quick path and invalid-option behavior now have test coverage

I also re-validated the latest revision locally, including the quick diagnostic path and tarball creation, and it looks good to merge.

Let it rip 🤙

@kjw3
kjw3 self-requested a review March 21, 2026 00:11
@kjw3
kjw3 merged commit 7d4c8e4 into NVIDIA:main Mar 21, 2026
3 checks passed
Ryuketsukami pushed a commit to Ryuketsukami/NemoClaw that referenced this pull request Mar 24, 2026
…#502)

* feat: add `nemoclaw debug` command for collecting diagnostics (NVIDIA#500)

Add a debug command that collects system, GPU, Docker, OpenShell, and
network diagnostics to help triage bug reports. Supports --quick for a
minimal subset and --output to produce a tarball for GitHub issues.

Also updates the bug report issue template to prompt users for debug
output.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

* fix: address CodeRabbit review feedback on debug script

- Add timeout/gtimeout detection for macOS compatibility
- Wrap piped commands in sh -c so collect() captures full pipeline
- Add sensitive data warning before tarball attachment prompt

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

* feat: collect in-sandbox diagnostics via openshell sandbox exec

Runs ps, free, top, and gateway log collection inside the sandbox when
it is reachable, addressing the full diagnostic scope from issue NVIDIA#500.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

* fix: address Aaron's review feedback

- Redact known sensitive patterns (API keys, tokens, passwords) from all
  collected output before saving to files or tarball
- Exit non-zero on unknown options instead of silently skipping
- Fix curl|bash example to use `bash -s -- --quick` syntax
- Add tests for `debug --quick` (runs collectors, exits 0) and unknown
  option rejection

Linux-specific commands (free, ss, vmstat, etc.) are already handled
gracefully by collect() which skips missing commands.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
jessesanford pushed a commit to jessesanford/NemoClaw that referenced this pull request Mar 24, 2026
…#502)

* feat: add `nemoclaw debug` command for collecting diagnostics (NVIDIA#500)

Add a debug command that collects system, GPU, Docker, OpenShell, and
network diagnostics to help triage bug reports. Supports --quick for a
minimal subset and --output to produce a tarball for GitHub issues.

Also updates the bug report issue template to prompt users for debug
output.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

* fix: address CodeRabbit review feedback on debug script

- Add timeout/gtimeout detection for macOS compatibility
- Wrap piped commands in sh -c so collect() captures full pipeline
- Add sensitive data warning before tarball attachment prompt

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

* feat: collect in-sandbox diagnostics via openshell sandbox exec

Runs ps, free, top, and gateway log collection inside the sandbox when
it is reachable, addressing the full diagnostic scope from issue NVIDIA#500.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

* fix: address Aaron's review feedback

- Redact known sensitive patterns (API keys, tokens, passwords) from all
  collected output before saving to files or tarball
- Exit non-zero on unknown options instead of silently skipping
- Fix curl|bash example to use `bash -s -- --quick` syntax
- Add tests for `debug --quick` (runs collectors, exits 0) and unknown
  option rejection

Linux-specific commands (free, ss, vmstat, etc.) are already handled
gracefully by collect() which skips missing commands.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
@wscurran wscurran added area: cli Command line interface, flags, terminal UX, or output feature PR adds or expands user-visible functionality and removed priority: high enhancement New capability or improvement request labels Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli Command line interface, flags, terminal UX, or output feature PR adds or expands user-visible functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add nemoclaw debug command for collecting diagnostic information

4 participants