Skip to content

fix(brev): reject invalid sandbox names before deploy - #2948

Merged
ericksoa merged 2 commits into
mainfrom
fix/brev-sandbox-name-validation
May 4, 2026
Merged

fix(brev): reject invalid sandbox names before deploy#2948
ericksoa merged 2 commits into
mainfrom
fix/brev-sandbox-name-validation

Conversation

@ericksoa

@ericksoa ericksoa commented May 3, 2026

Copy link
Copy Markdown
Contributor

fixes #2869

Summary

  • Route Brev deploy sandbox-name validation through a plain early error instead of letting the canonical validator escape as terse UX.
  • Share the sandbox-name allowed-format wording with onboard so prompts and non-interactive errors say: lowercase, starts with a letter, letters/numbers/internal hyphens only, ends with letter/number.
  • Add regression coverage that invalid NEMOCLAW_SANDBOX_NAME fails before Brev provisioning, SSH, or installer handoff.

What was late/missing before

Brev deploy did call validateName, but invalid env input surfaced as a raw validation failure without Brev-specific guidance or an explicit non-interactive correction path. The onboard prompt also used shorter wording that did not state the complete rule before entry.

Where Brev now validates early

src/lib/deploy.ts validates NEMOCLAW_SANDBOX_NAME immediately after resolving deploy flags and before credentials, brev, SSH, rsync, or installer work. Invalid names with spaces now print that spaces are not allowed and tell the user to set a valid NEMOCLAW_SANDBOX_NAME.

Tests run

  • npm run build:cli
  • npx vitest run src/lib/deploy.test.ts
  • npx vitest run test/e2e/brev-e2e.test.ts
  • npx vitest run test/onboard.test.ts -t "sandbox name|invalid sandbox|re-prompts"
  • npx vitest run test/smoke-macos-install.test.ts -t "invalid sandbox"
  • git diff --check

Summary by CodeRabbit

  • New Features

    • Standardized sandbox name validation guidance across deploy and onboarding commands
    • Help and interactive prompts now display the allowed sandbox name format
  • Bug Fixes

    • Clearer, consistent error messages when sandbox names are invalid
    • Deploy shows explicit non-interactive guidance and prevents provisioning on invalid names
  • Tests

    • Added deploy validation e2e test and extended sandbox name validation tests

@coderabbitai

coderabbitai Bot commented May 3, 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: Enterprise

Run ID: c54e26e3-a023-4ed9-b4d1-ece675d170e6

📥 Commits

Reviewing files that changed from the base of the PR and between 7834342 and bffab59.

📒 Files selected for processing (2)
  • src/lib/deploy.test.ts
  • src/lib/runner.ts
✅ Files skipped from review due to trivial changes (2)
  • src/lib/runner.ts
  • src/lib/deploy.test.ts

📝 Walkthrough

Walkthrough

A new centralized name-validation module (name-validation.ts) defines consistent guidance messages and allowed-format text. runner.ts, deploy.ts, and onboard.ts consume it to standardize sandbox-name validation output for interactive and non-interactive flows. Tests were added/updated to assert the guidance appears and invalid names are rejected early.

Changes

Centralized Name Validation Guidance

Layer / File(s) Summary
Core Validation Data
src/lib/name-validation.ts
New module exports NAME_ALLOWED_FORMAT and getNameValidationGuidance(label, value, opts?) to produce consistent guidance lines (includes whitespace check and optional "Allowed format" line).
Validation Message Update
src/lib/runner.ts
validateName() error messages now append Allowed format: ${NAME_ALLOWED_FORMAT} for required/too-long/invalid-format cases.
Deploy Flow Integration
src/lib/deploy.ts
Adds validateDeploySandboxName(...) that wraps validateName and on failure prints the validation error plus guidance (without allowed-format) and a non-interactive remediation note; executeDeploy uses this helper. Usage/help text now includes NAME_ALLOWED_FORMAT.
Onboard Flow Integration
src/lib/onboard.ts
promptValidatedSandboxName() and early non-prompt validation now use getNameValidationGuidance("sandbox name", value, { includeAllowedFormat: false }) instead of bespoke messages.
Tests & E2E
src/lib/deploy.test.ts, test/onboard.test.ts, test/e2e/brev-e2e.test.ts
Updated and new tests import deployed validation, assert guidance usage and that prompts/display include NAME_ALLOWED_FORMAT, and assert non-interactive deploy exits early without starting provisioning when name is invalid.

Sequence Diagram

sequenceDiagram
    actor User
    participant Onboard as onboard()
    participant Deploy as deploy.ts
    participant Validate as validateName()
    participant Guidance as getNameValidationGuidance()

    User->>Onboard: Enter sandbox name
    Onboard->>Validate: validateName(input, "sandbox name")
    alt Invalid Name
        Validate-->>Onboard: Throw ValidationError
        Onboard->>Guidance: getNameValidationGuidance("sandbox name", input, includeAllowedFormat: false)
        Guidance-->>Onboard: Return guidance lines
        Onboard-->>User: Show guidance & retry or abort
    else Valid Name
        Validate-->>Onboard: ✓
        Onboard->>User: Proceed
    end

    User->>Deploy: Run deploy with NEMOCLAW_SANDBOX_NAME
    Deploy->>Validate: validateDeploySandboxName(envValue)
    alt Invalid Name
        Validate-->>Deploy: Throw ValidationError
        Deploy->>Guidance: getNameValidationGuidance("sandbox name", envValue, includeAllowedFormat: false)
        Guidance-->>Deploy: Return guidance lines
        Deploy-->>User: Print error & exit(1)
    else Valid Name
        Validate-->>Deploy: ✓
        Deploy->>User: Proceed with provisioning
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A hop, a check, a gentle chime,

No spaces now, one steady rhyme,
From prompt to deploy the message clear,
One format shown for all to hear,
A tidy name, a smoother year.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.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 specifically describes the main change: adding validation to reject invalid sandbox names before Brev deployment.
Linked Issues check ✅ Passed Changes comprehensively address issue #2869: validation is performed early before provisioning, guidance text is explicit and consistent, and Brev behavior aligns with Spark path requirements.
Out of Scope Changes check ✅ Passed All changes are directly scoped to sandbox-name validation for deploy and onboard flows; no extraneous modifications detected.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/brev-sandbox-name-validation

Review rate limit: 9/10 reviews remaining, refill in 6 minutes.

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.

🧹 Nitpick comments (1)
src/lib/deploy.test.ts (1)

240-248: ⚡ Quick win

Assert the env-var remediation hint explicitly.

This test validates format guidance well, but it does not lock the promised “set a valid NEMOCLAW_SANDBOX_NAME” remediation text. Adding one assertion will catch regressions in the user-facing guidance path.

Proposed assertion addition
     expect(errorText).toContain(
       "Brev deploy is non-interactive and cannot prompt for a corrected sandbox name.",
     );
+    expect(errorText).toMatch(/set\s+.*NEMOCLAW_SANDBOX_NAME/i);
     expect(fixture.calls).toEqual([]);
     expect(fixture.interactive).toEqual([]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lib/deploy.test.ts` around lines 240 - 248, Add an assertion to the test
that verifies the remediation hint about setting the NEMOCLAW_SANDBOX_NAME env
var is present in the aggregated error text: locate the test that builds
errorText from fixture.errors (variable errorText) in deploy.test.ts and add an
expect(errorText).toContain(...) checking for the exact remediation message that
tells users to set a valid NEMOCLAW_SANDBOX_NAME.
🤖 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/deploy.test.ts`:
- Around line 240-248: Add an assertion to the test that verifies the
remediation hint about setting the NEMOCLAW_SANDBOX_NAME env var is present in
the aggregated error text: locate the test that builds errorText from
fixture.errors (variable errorText) in deploy.test.ts and add an
expect(errorText).toContain(...) checking for the exact remediation message that
tells users to set a valid NEMOCLAW_SANDBOX_NAME.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: fb092237-52a4-425d-8e02-99f18ef0bd82

📥 Commits

Reviewing files that changed from the base of the PR and between 4f7f7e5 and 7834342.

📒 Files selected for processing (7)
  • src/lib/deploy.test.ts
  • src/lib/deploy.ts
  • src/lib/name-validation.ts
  • src/lib/onboard.ts
  • src/lib/runner.ts
  • test/e2e/brev-e2e.test.ts
  • test/onboard.test.ts

@github-actions

github-actions Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor

Brev E2E (full): FAILED on branch fix/brev-sandbox-name-validationSee logs

@ericksoa
ericksoa requested a review from cv May 3, 2026 23:03
@ericksoa ericksoa added the platform: brev Affects Brev hosted development environments label May 3, 2026
@ericksoa ericksoa self-assigned this May 4, 2026
@ericksoa
ericksoa merged commit eab7c2a into main May 4, 2026
23 of 25 checks passed
miyoungc added a commit that referenced this pull request May 5, 2026
## Summary
Catch up the docs for user-facing changes that landed over the weekend
and today, so the published guidance matches current installer,
onboarding, status, logs, local inference, rebuild backup behavior, the
next docs version selector, and refreshed generated user skills.

## Related Issue
None.

## Changes
- Document WSL Windows-host Ollama onboarding actions, including use,
start, restart, install, and `host.docker.internal` model pulls from
#2800; clarify that onboard owns Ollama install and model pulls from
#2952.
- Document installer fail-fast behavior for non-TTY third-party software
acceptance from #2706.
- Update sandbox-name guidance and Brev deploy validation behavior from
#2948.
- Add `nemoclaw <name> logs --tail/--since` coverage from #2825.
- Add global `nemoclaw status --json` coverage from #2822.
- Document verified-gateway status behavior and non-zero degraded exits
from #2884.
- Clarify that rebuild stops before deleting the original sandbox when
backup fails, including unreadable or root-owned state paths.
- Bump docs switcher metadata from 0.0.33 to 0.0.34 without changing
package versions or creating release tags.
- Regenerate `.agents/skills/nemoclaw-user-*` from docs, including the
new `nemoclaw-user-manage-sandboxes` generated skill and removal of the
stale `nemoclaw-user-workspace` output.

## Type of Change
- [ ] Code change (feature, bug fix, or refactor)
- [ ] Code change with doc updates
- [ ] Doc only (prose changes, no code sample modifications)
- [x] Doc only (includes code sample changes)

## Verification
- [ ] `npx prek run --all-files` passes
- [ ] `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)

---
<!-- DCO sign-off required by CI. Run: git config user.name && git
config user.email -->
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

* **Documentation**
* Expanded Ollama/local inference guidance with detailed WSL and
Windows-host workflows, proxy/token behavior, and onboarding options
* Standardized sandbox name validation and updated troubleshooting, CLI,
and deploy docs to surface the rules and validation timing
* Added/rewrote Manage Sandboxes, policy management, backup/restore,
messaging channels, workspace persistence, and CLI selection guides
* Refreshed quickstart/Hermes guidance, skill mappings, and bumped docs
version to 0.0.34
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
@wscurran wscurran added the bug-fix PR fixes a bug or regression label Jun 8, 2026
@wscurran wscurran added NV QA Bugs found by the NVIDIA QA Team UAT Issues flagged for User Acceptance Testing. VDR Linked to VDR finding labels Jun 26, 2026
@cv
cv deleted the fix/brev-sandbox-name-validation branch June 28, 2026 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix PR fixes a bug or regression NV QA Bugs found by the NVIDIA QA Team platform: brev Affects Brev hosted development environments UAT Issues flagged for User Acceptance Testing. VDR Linked to VDR finding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VDR 4: Sandbox name validation remains easy to miss on Brev

3 participants