Skip to content

fix(cli): validate deploy instance names before setup prompts - #604

Closed
Saibabu7770 wants to merge 1 commit into
NVIDIA:mainfrom
Saibabu7770:fix/deploy-instance-name-validation-575
Closed

Saibabu7770 wants to merge 1 commit into
NVIDIA:mainfrom
Saibabu7770:fix/deploy-instance-name-validation-575

Conversation

@Saibabu7770

@Saibabu7770 Saibabu7770 commented Mar 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #575.

Summary

Validate nemoclaw deploy <instance-name> input before credential/setup steps.
This fails fast on malformed names and prevents API key prompt for invalid input.

Changes

  • Validate instanceName at start of deploy() in bin/nemoclaw.js
  • Exit with clear error when name is invalid
  • Add CLI regression tests in test/cli.test.js for:
    • foo;bar
    • $(id)

Testing

  • node --test --test-name-pattern "deploy rejects" test/cli.test.js
  • Manual check: invalid name is rejected immediately
  • Manual check: valid name proceeds past validation

Summary by CodeRabbit

  • Bug Fixes

    • Deployment now validates instance names immediately, rejects invalid names with a clear error message, and exits early without prompting for credentials.
  • Tests

    • Added CLI tests ensuring malformed instance names (including shell metacharacters) fail early, emit the expected error, and do not trigger credential prompts.

@coderabbitai

coderabbitai Bot commented Mar 21, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The deploy(instanceName) function in bin/nemoclaw.js now performs instance-name validation inside a guarded try/catch immediately after the non-empty check and exits with code 1 on validation failure. Two CLI tests were added to test/cli.test.js asserting names with shell metacharacters are rejected before any credential prompt.

Changes

Cohort / File(s) Summary
Deploy input validation
bin/nemoclaw.js
Move validateName(instanceName, "instance name") into a try/catch immediately after the non-empty check; on failure log err.message and call process.exit(1); remove unguarded validation and use the validated name for subsequent shell invocations.
CLI tests for validation
test/cli.test.js
Add two CLI dispatch tests passing instance names with shell metacharacters ("foo;bar", "$(id)") expecting exit code 1, an "Invalid instance name" error message, and no downstream credential-prompt output.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 I sniff a name with cautious nose,
I nudge out tricks where mischief grows.
No rogue semicolon, no secret subs,
I guard the hops and tidy the hubs.
Hop—deploy is safe, no slippery snubs.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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 'fix(cli): validate deploy instance names before setup prompts' accurately summarizes the main change: adding instance-name validation before credential prompts in the deploy command.
Linked Issues check ✅ Passed The PR successfully implements the primary objective from issue #575: validate instance names before shell command execution to prevent command injection, adding input validation and early exit for malformed names.
Out of Scope Changes check ✅ Passed All changes are scoped to instance-name validation: bin/nemoclaw.js adds validation logic and test/cli.test.js adds regression tests covering shell metacharacters, both directly addressing issue #575.

✏️ 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.

@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 the current code and only fix it if needed.

Inline comments:
In `@test/cli.test.js`:
- Around line 102-104: The test "deploy rejects command-substitution instance
names" is currently using double quotes so the shell expands $(id) before it
reaches the CLI; update the test to pass a literal $(id) by changing the call to
run in that test (the run(...) invocation in test/cli.test.js) to use single
quotes around $(id) (i.e., run("deploy '$(id)'") ) so the shell does not perform
command substitution and the CLI receives the raw payload to validate.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 35943e3b-b885-4659-bc54-40ff08c07eaf

📥 Commits

Reviewing files that changed from the base of the PR and between 255e606 and d23b193.

📒 Files selected for processing (2)
  • bin/nemoclaw.js
  • test/cli.test.js

Comment thread test/cli.test.js Resolved
@wscurran

Copy link
Copy Markdown
Contributor

Thanks for the proposed fix to validate deploy instance names before setup prompts, which may help prevent issues with malformed names and improve the overall user experience.

@wscurran

Copy link
Copy Markdown
Contributor

Thanks for this — validating deploy instance names early prevents confusing failures downstream. The CLI has been refactored to TypeScript since March. Could you rebase against main and verify the validation still fits the current deploy flow? Happy to review once it's updated.

Wrap validateName for instance and sandbox in executeDeploy so invalid names
exit with code 1 and a clear message instead of throwing. Add unit and CLI
regression tests that ensure credentials are not read for bad deploy names.

Made-with: Cursor
@Saibabu7770
Saibabu7770 force-pushed the fix/deploy-instance-name-validation-575 branch from 7eb2e25 to d12420b Compare April 16, 2026 04:14
@wscurran

Copy link
Copy Markdown
Contributor

Thanks for the contribution. Instance name validation for nemoclaw deploy was actually merged in before this PR was opened — validateName is already enforced on the deploy path in main. Closing as the change is already covered.

Feel free to check the current state of src/lib/deploy.ts if you have other improvements in mind.

@wscurran wscurran closed this Apr 16, 2026
@wscurran wscurran added area: cli Command line interface, flags, terminal UX, or output bug-fix PR fixes a bug or regression needs: rebase PR needs rebase or conflict resolution and removed NemoClaw CLI labels Jun 3, 2026
cv added a commit that referenced this pull request Nov 6, 2026
NemoClaw v1 no longer offers the Deep Agents Code harness
(`nvidia.fabric.langchain.deepagents-code`), and pins a Fabric revision
without its adapter. The LangChain Deep Agents harness
(`nvidia.fabric.langchain.deepagents`) stays as it is.

## Problem

The Deep Agents Code integration is on hold: its Fabric adapter pull
requests, NVIDIA/NeMo-Fabric#571 and #575, are closed. `v1` still pins
Fabric `e5b5ebf2`, which merges both, and builds, catalogs, documents,
and live-tests a `deepagents-code` image.

## Change

What users lose:

- the `deepagents-code` agent image and Bake target, and the harness's
entry in the bundled catalog;
- `examples/fabric-deepagents-code.yaml`;
- the `terminal` interface: apply no longer prints an `Open` command,
and JSON `interfaces` entries no longer carry `launcher` or `signIn:
sandbox_exec`.

The Fabric pin moves to `934ab7eca1ec9ac86a22fd24913f2e9d68637c4a`,
branch `integration/nemoclaw-pin-no-dcode` on `cv/NeMo-Fabric`. It
starts from NVIDIA/NeMo-Fabric `main` at `035bc2fe`, which has #568 and
#569, and merges the head branches of #570, #573, #574, #572, and #576,
in that order.

- #574's branch contains #573's and then removes OpenClaw's Control UI
to keep the two pull requests' diffs apart (`9855259c`). Merging both
dropped the Control UI, so the branch reverts that commit; OpenClaw's
files then match #573's head.
- The one textual conflict, in Fabric's
`docs/integrations/harness/hermes.mdx`, keeps #574's layout and adds
#576's `runtime.keep_state` paragraph.
- The regenerated `image/fabric/catalog.json` differs from `e5b5ebf2`'s
only by the removed adapter and the revision; the other 11 descriptors
are unchanged. OpenClaw's supported version is still 2026.9.34.
- The fixture image the HCL cases name, and the registration names in
`openshift-external-two-providers`, follow the new catalog.

`SignIn::SandboxExec`, the interface `launcher` field, and their CLI
output and tests are removed. Only Deep Agents Code's terminal used
them. Pi's descriptor at the new pin declares no interfaces, and no open
NeMo-Fabric pull request adds one: the two that touch Pi, #604 and #595,
change a health test and the README.

The four model-tuning tests from #14111 keep their check, and now select
Codex instead of Deep Agents Code. Codex accepts only `models.base_url`
among model fields and declares no model extension. Pi isn't used: its
`config.accepts` lists only `models.base_url`, but its model extension
declares `max_tokens`, which planning accepts as a legacy extension
field, so the `maxTokens` cases fail with Pi.

The Docker live suite and `cargo ci live-images` no longer build or pull
a `deepagents-code` image. The verify-yaml-deployment skill drops its
Deep Agents Code agent and terminal feature; verify-fabric-boundary now
carries, in its native-interfaces page, the pseudo-terminal driver its
`tui` check took from that feature. Fern's redirects for the old Deep
Agents Code quickstart pages stay.

## Beyond CI

- Fabric `934ab7ec`: its Rust workspace tests, except `fabric-python`,
which needs `libpython3.12` to link; its Python suite (3,282 passed);
and its TypeScript tests passed. The OpenCode tests failed because the
host has Bun 1.3.14 and the adapter needs 1.4.2 or later. `just
check-adapter-catalog` passed.
- GitHub's `codeload` archives of `934ab7ec` under `NVIDIA/NeMo-Fabric`
and `cv/NeMo-Fabric` have the pinned SHA-256.
- On `linux_arm64`, `cargo images build` built all 11 production agent
images and the reference image, `cargo images qualify` passed for all
12, and `catalog.py` run with the built Claude Code image's interpreter
reproduced the committed catalog. `cargo ci live-docker` passed.
- With the tuning check disabled, the three rejection tests failed;
counting a null extension as set failed the fourth.

Not run: `cargo ci live-kind`, and the images on `linux/amd64`; the
Kubernetes images change only by the Fabric pin.
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 bug-fix PR fixes a bug or regression needs: rebase PR needs rebase or conflict resolution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MEDIUM: Unvalidated Instance Name in deploy() Shell Commands

2 participants