fix(onboard): reject sandbox names starting with a digit and allow retry#1125
fix(onboard): reject sandbox names starting with a digit and allow retry#1125latenighthackathon wants to merge 8 commits intoNVIDIA:mainfrom
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughSandbox name validation now requires names to start with a lowercase ASCII letter and match Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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)
test/onboard.test.js (1)
443-459: Avoid duplicating the production regex literal in the test.This test can drift from runtime validation because it redefines the pattern locally. Consider exporting a shared sandbox-name validator (or regex constant) from
bin/lib/onboard.jsand asserting against that single source of truth.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/onboard.test.js` around lines 443 - 459, The test currently redefines SANDBOX_NAME_REGEX locally which can drift from production; export the shared validator (e.g., a named export SANDBOX_NAME_REGEX or a function validateSandboxName) from bin/lib/onboard.js, update the test to import that exported symbol instead of defining its own regex, and assert against the imported constant/function (replace local SANDBOX_NAME_REGEX usage with the imported symbol or call validateSandboxName) so the test uses the single source of truth.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@test/onboard.test.js`:
- Around line 443-459: The test currently redefines SANDBOX_NAME_REGEX locally
which can drift from production; export the shared validator (e.g., a named
export SANDBOX_NAME_REGEX or a function validateSandboxName) from
bin/lib/onboard.js, update the test to import that exported symbol instead of
defining its own regex, and assert against the imported constant/function
(replace local SANDBOX_NAME_REGEX usage with the imported symbol or call
validateSandboxName) so the test uses the single source of truth.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6cec9920-7f3f-4eef-9d99-575ac761567c
📒 Files selected for processing (2)
bin/lib/onboard.jstest/onboard.test.js
|
✨ Thanks for submitting this PR with a detailed summary, it proposes to address an onboarding issue by improving sandbox name validation.. |
Names starting with a digit (e.g., '7racii') pass the current regex but fail downstream in Kubernetes. The user is forced to delete ~/.nemoclaw to recover because the invalid name is persisted in the session and reused on retry. Tighten the regex from ^[a-z0-9] to ^[a-z] so digit-prefixed names are caught at prompt time. Replace process.exit(1) with a retry loop (up to 3 attempts) so users can correct the name without restarting. Non-interactive mode still exits immediately on invalid input. Signed-off-by: latenighthackathon <latenighthackathon@users.noreply.github.com>
64e333e to
beee1a0
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
bin/lib/onboard.js (1)
2280-2281: Minor inconsistency: error message says "start with a letter or number" but rule is letter-only.The generic error message claims names can start with "a letter or number," but the regex
^[a-z]requires a letter. While the digit-prefixed case has its own specific message, other invalid cases (e.g.,-abc,ABC) would show this slightly misleading text.💡 Suggested fix for error message accuracy
} else { - console.error(" Names must be lowercase, contain only letters, numbers, and hyphens,"); - console.error(" and must start and end with a letter or number."); + console.error(" Names must be lowercase, contain only letters, numbers, and hyphens,"); + console.error(" must start with a letter, and end with a letter or number."); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@bin/lib/onboard.js` around lines 2280 - 2281, The error text printed in onboard.js is inconsistent with the validation regex (which uses ^[a-z] to require names to start with a lowercase letter); update the two console.error lines that describe allowed names so they accurately state that names must start with a lowercase letter (not "a letter or number") — reference the validation using the ^[a-z] rule and adjust the message to say something like "Names must be lowercase, contain only letters, numbers, and hyphens, and must start with a lowercase letter and end with a letter or number." Ensure the updated text replaces the existing console.error lines.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@bin/lib/onboard.js`:
- Around line 2280-2281: The error text printed in onboard.js is inconsistent
with the validation regex (which uses ^[a-z] to require names to start with a
lowercase letter); update the two console.error lines that describe allowed
names so they accurately state that names must start with a lowercase letter
(not "a letter or number") — reference the validation using the ^[a-z] rule and
adjust the message to say something like "Names must be lowercase, contain only
letters, numbers, and hyphens, and must start with a lowercase letter and end
with a letter or number." Ensure the updated text replaces the existing
console.error lines.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3ed6025f-380b-4441-8fc7-75ac4eeadb70
📒 Files selected for processing (2)
bin/lib/onboard.jstest/onboard.test.js
✅ Files skipped from review due to trivial changes (1)
- test/onboard.test.js
The generic error said names can start with "a letter or number" but the regex requires a letter. Update to match the actual rule.
There was a problem hiding this comment.
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 `@bin/lib/onboard.js`:
- Around line 2261-2296: Update the test that asserts promptValidatedSandboxName
uses an infinite loop: instead of looking for a while(true) pattern, change the
assertion to verify the new bounded-retry implementation by checking for the
MAX_ATTEMPTS constant or the for-loop pattern (e.g., assert the function body
contains "MAX_ATTEMPTS" or a for loop like "for (let attempt" / "for\\s*\\(let
attempt") and/or that it exits with process.exit(1) after too many attempts;
reference the promptValidatedSandboxName function and MAX_ATTEMPTS in your test
modification so it matches the new behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 44ef639f-d66d-47ab-a7db-9a2a8d47cef5
📒 Files selected for processing (1)
bin/lib/onboard.js
The test expected while(true) but the implementation uses a bounded for-loop with MAX_ATTEMPTS. Update the assertion to match.
Assert that promptValidatedSandboxName uses MAX_ATTEMPTS for bounded retries and exits with "Too many invalid attempts" after exhaustion.
Signed-off-by: latenighthackathon <latenighthackathon@users.noreply.github.com>
51b7400 to
c69d559
Compare
Summary
Names starting with a digit (e.g.,
7racii) pass the current validation regex but fail downstream in Kubernetes. The user is then stuck in a loop because the invalid name is persisted in the onboard session and reused on retry — the only recovery is deleting~/.nemoclaw.Related Issue
Closes #1120
Changes
^[a-z0-9]to^[a-z]so digit-prefixed names are caught at prompt timeprocess.exit(1)with a retry loop (up to 3 attempts) so users can correct the name interactivelyTesting
npm testpasses (no local environment)Executed:
npx vitest run test/onboard.test.js -t "rejects sandbox names"passes in Docker (Linux)Checklist
Summary by CodeRabbit
Bug Fixes
Tests
Signed-off-by: latenighthackathon latenighthackathon@users.noreply.github.com