Skip to content

fix(state): accept dashboardPort 0 as no dashboard - #7021

Merged
apurvvkumaria merged 4 commits into
mainfrom
fix/registry-dashboard-port-zero
Jul 16, 2026
Merged

fix(state): accept dashboardPort 0 as no dashboard#7021
apurvvkumaria merged 4 commits into
mainfrom
fix/registry-dashboard-port-zero

Conversation

@laitingsheng

@laitingsheng laitingsheng commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

The gateway registry parser rejected a persisted dashboardPort of 0 — the value a no-dashboard (dcode) sandbox records — and threw for the entire registry read, so one such row blocked every registry operation (list, onboard, rebuild) and could leave a rebuilt sandbox destroyed and unrecreatable until the file was hand-edited. Registry reads now treat 0 as "no dashboard" (equivalent to null), and registry writes canonicalize either form to null, so one legacy row can no longer fail host-wide parsing and future writes converge on the canonical representation.

Related Issue

Fixes #7020

Changes

  • src/lib/state/gateway-registry.ts: parseRegistry accepts a dashboardPort of 0, rejecting only negative, non-integer, or out-of-range values, and normalizes a stored 0 to null in memory so every consumer treats it as no dashboard.
  • src/lib/state/registry.ts: registry serialization canonicalizes dashboardPort: 0 to null. An existing on-disk 0 is safe immediately on read and is persisted as null the next time the registry is written.
  • src/lib/state/gateway-registry.test.ts: adds a regression test asserting a persisted 0 parses and is surfaced as no dashboard instead of throwing.
  • src/lib/onboard/sandbox-registry-metadata.test.ts: verifies a reused dcode sandbox is persisted and listed with dashboardPort: null, and that a later sandbox allocation still sees the dashboard port as available.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Docs updated for user-facing behavior changes
  • Docs not applicable — justification: internal registry-parser and persistence normalization; no user-facing flag, output, or configurable behavior changes.
  • Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging)
  • Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: parsing and serialization are limited to dashboardPort; path-safety (O_NOFOLLOW, symlink rejection), size-limit, and gateway-identity guards are untouched — maintainer review requested.
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Verification

  • PR description includes a Signed-off-by: line and every commit appears as Verified in GitHub
  • Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run check:diff passed when hooks were skipped or unavailable
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — contributor validation: npx vitest run src/lib/state/gateway-registry.test.ts → 5/5 passed; adjacent dashboard-port + registry-normalization → 42/42 passed. Current-head remote CLI shards, static checks, type checks, security checks, and installer/plugin suites are green.
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — command/result:
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • npm run docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Tinson Lai tinsonl@nvidia.com

Summary by CodeRabbit

  • Bug Fixes
    • Corrected handling of persisted sandboxes configured with dashboardPort: 0, treating them as having no dashboard.
    • Updated validation to allow dashboardPort values from 0 to 65535, while still rejecting out-of-range inputs.
    • Prevented registry listing/allocation from being blocked by a dashboardPort value of 0.
  • Tests
    • Added coverage for reused terminal sandboxes and gateway registry behavior when dashboardPort is 0.
  • Documentation
    • Documented the persistence normalization of dashboardPort: 0 to “no dashboard” (null).

A dcode sandbox persists dashboardPort 0 to mean "no dashboard", but the gateway
registry parser rejected any value below 1 and threw for the entire read, so a
single entry blocked every registry operation (list, onboard, rebuild) and could
leave a rebuilt sandbox destroyed. Treat 0 as no dashboard (normalise to null) so
one row can no longer fail the whole registry.

Fixes #7020

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The gateway registry and sandbox persistence now treat dashboardPort: 0 as no dashboard by normalizing it to null, with regression coverage for registry loading, reused sandbox metadata, and port allocation.

Changes

Dashboard port normalization

Layer / File(s) Summary
Persistence normalization and reused sandbox coverage
src/lib/state/registry.ts, src/lib/onboard/sandbox-registry-metadata.test.ts
Persisted dashboard port zero values are converted to null; reused sandbox metadata tests verify registry output and subsequent port allocation.
Registry parser and regression coverage
src/lib/state/gateway-registry.ts, src/lib/state/gateway-registry.test.ts
Validation permits ports from 0 through 65535, converts zero to null, preserves non-zero ports, and tests loading a registry containing dashboardPort: 0.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: area: sandbox

Suggested reviewers: cv, yimoj

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The parser now accepts 0, normalizes it to null, and the added tests cover the behavior required by #7020.
Out of Scope Changes check ✅ Passed Changes are limited to the registry fix, regression tests, and matching docs; no unrelated scope is apparent.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: treating dashboardPort 0 as no dashboard in state handling.
✨ 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/registry-dashboard-port-zero

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

@laitingsheng laitingsheng added the bug-fix PR fixes a bug or regression label Jul 16, 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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/state/gateway-registry.test.ts`:
- Line 72: Update the test title in the zero persisted dashboard port case to
end with the issue reference suffix "(`#7020`)", preserving the existing title
text and 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: Enterprise

Run ID: 025b97ef-f55a-482d-9632-aaf598629539

📥 Commits

Reviewing files that changed from the base of the PR and between b528371 and 1b010a7.

📒 Files selected for processing (2)
  • src/lib/state/gateway-registry.test.ts
  • src/lib/state/gateway-registry.ts

Comment thread src/lib/state/gateway-registry.test.ts Outdated
@github-code-quality

github-code-quality Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage remains at 96%, unchanged from the main branch.

TypeScript / code-coverage/cli

The overall coverage in the fix/registry-dashboa... branch remains at 80%, unchanged from the main branch.

Show a code coverage summary of the most impacted files.
File main d034b7f fix/registry-dashboa... 13f2af5 +/-
src/lib/core/pr...mpt-activity.ts 92% 67% -25%
src/lib/inferen...er-lifecycle.ts 71% 65% -6%
src/lib/credentials/store.ts 64% 59% -5%
src/lib/onboard...host-anchors.ts 94% 90% -4%
src/lib/actions...eway-restart.ts 93% 90% -3%
src/lib/onboard...u-patch-mode.ts 93% 90% -3%
src/lib/messagi...flow-planner.ts 93% 93% 0%
src/lib/state/registry.ts 83% 86% +3%
src/lib/state/g...way-registry.ts 90% 94% +4%
src/lib/onboard...box-prebuild.ts 69% 88% +19%

Updated July 16, 2026 17:22 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — Informational

Advisor assessment: Informational / high confidence
Next action: Review the warnings below.
Findings: 0 blockers · 1 warning · 0 suggestions
Status: Canonical ledger: 0 blocker(s), 1 warning(s), 0 suggestion(s).

Model lanes

  • GPT-5.6 Terra (primary): Completed · high confidence · 0 blockers · 1 warning · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Completed · high confidence · 0 blockers · 0 warnings · 0 suggestions
  • Model comparison: normalized findings differ; normalized E2E selections differ; Nemotron reported the same number of blockers, 1 fewer warning, the same number of suggestions.

Nemotron output stays in workflow artifacts and does not change the assessment above.

E2E guidance

Advisory only. E2E / PR Gate selects and runs jobs independently.

Recommended E2E: onboard-repair, onboard-resume, cloud-onboard

2 optional E2E recommendations
  • sandbox-rebuild
  • ubuntu-repo-cloud-langchain-deepagents-code
1 warning · 0 suggestions

Warnings

Warnings do not block.

PRA-1 Warning — Cover legacy zero-dashboard state during lifecycle recovery

  • Location: test/e2e/live/onboard-resume.test.ts:156
  • Category: tests
  • Problem: The changed unit tests establish parsing and allocation behavior for an unrelated persisted `dashboardPort: 0` entry, but the lifecycle recovery suites do not seed that legacy state before resuming or repairing a dashboard-bearing sandbox. The affected path can fail after destructive rebuild/recreate work, so unit coverage alone does not demonstrate that a retry converges with no stale allocation.
  • Impact: A regression in the integration between registry parsing, host-wide port allocation, and recovery could again leave a target sandbox unrecreated or allocate a stale port when an unrelated terminal/dcode row contains the legacy zero sentinel.
  • Recommendation: Add one focused recovery regression that seeds an unrelated no-dashboard registry row with `dashboardPort: 0`, runs resume or repair for a dashboard-bearing sandbox, and asserts successful completion and a non-conflicting allocated dashboard port.
  • Verification: Inspect `test/e2e/live/onboard-resume.test.ts` and `test/e2e/live/onboard-repair.test.ts` for a setup that writes an unrelated zero-dashboard registry row before recovery; none is present in the reviewed evidence.
  • Test coverage: A live `onboard-resume` or `onboard-repair` case that seeds an unrelated `dashboardPort: 0` entry, triggers target recovery, and verifies target recreation succeeds without treating the zero entry as occupied.
  • Evidence: `src/lib/state/gateway-registry.ts` now changes parser behavior for persisted zero dashboard ports used by host-wide allocation. The added unit tests cover parsing/canonicalization and an allocator result, not a resume or repair operation. Risk plan lists lifecycle-state invariant: partial failure and retry converge without ghost resources or stale ports, with `onboard-resume` and `onboard-repair` as required jobs.

Workflow run details

This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge.

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
@apurvvkumaria apurvvkumaria self-assigned this Jul 16, 2026
apurvvkumaria and others added 2 commits July 16, 2026 10:02
Persist the no-dashboard zero sentinel as null at the common registry
serialization boundary while retaining reader compatibility for existing
state.

Add focused coverage from reused terminal-sandbox metadata through persisted
registry reads and host dashboard-port allocation.

Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Co-authored-by: Tinson Lai <tinsonl@nvidia.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>

@cv cv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at exact head 13f2af5 against current base d034b7f. The refresh commit is merge-only and preserves the reviewed patch; parser, persistence, and allocation tests cover the dashboardPort 0 sentinel. All 54 current checks and exact-diff E2E are green, CodeRabbit is clear, DCO is present, and all commits are Verified.

@apurvvkumaria
apurvvkumaria merged commit b485249 into main Jul 16, 2026
75 checks passed
@apurvvkumaria
apurvvkumaria deleted the fix/registry-dashboard-port-zero branch July 16, 2026 17:56
cv pushed a commit that referenced this pull request Jul 17, 2026
<!-- markdownlint-disable MD041 -->
## Summary

Add the canonical dated changelog entry required before the v0.0.85
release plan can be generated.
The entry summarizes the user-visible OpenShell, DGX Station, inference,
MCP, onboarding, and recovery changes merged since v0.0.84 and links to
their owning guides.

## Changes

- Add `docs/changelog/2026-07-16.mdx` with the exact `## v0.0.85`
heading, parser-safe SPDX comment, release summary, and detailed
bullets.
- Link every documented theme to its most specific published OpenClaw
guide routes.
- Reconcile the release entry with these merged source PRs:
- #6726 -> `docs/changelog/2026-07-16.mdx`: Document the supported
OpenShell v0.0.85 upgrade, immutable consumed artifacts, multiline exec,
credential rewrite diagnostics, and child-process TLS boundary.
- #6986 -> `docs/changelog/2026-07-16.mdx`: Document managed MCP
behavior shared across supported agents.
- #6991 and #7045 -> `docs/changelog/2026-07-16.mdx`: Document qualified
DGX Station host preparation and the interactive-terminal boundary for
`--station-deepseek`.
- #6992, #7001, #7006, and #7044 -> `docs/changelog/2026-07-16.mdx`:
Document managed-model reasoning behavior, safe inference route
mutation, and verified vLLM served aliases.
- #6865, #7010, and #7028 -> `docs/changelog/2026-07-16.mdx`: Document
onboarding DNS recovery, explicit notice acceptance, and upgrades with
user-local OpenShell.
- #7005, #7021, #7029, and #7049 -> `docs/changelog/2026-07-16.mdx`:
Document rebuild backup safety, no-dashboard state, managed gateway
discovery, and Hermes shields topology checks.

## 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)

## Quality Gates

- [ ] Tests added or updated for changed behavior
- [x] Existing tests cover changed behavior — justification:
`test/changelog-docs.test.ts` validates the canonical heading,
parser-safe SPDX comment, and detailed entry structure; the docs build
validates published routes.
- [ ] Tests not applicable — justification:
- [x] Docs updated for user-facing behavior changes
- [ ] Docs not applicable — justification:
- [ ] Sensitive paths changed (security, policy, credentials, preflight,
onboarding, inference, runner, sandbox, or messaging)
- [ ] Sensitive-path review completed or maintainer-approved waiver
recorded — reviewer/approval link/justification:
- [ ] Non-success, skipped, or missing CI check accepted by maintainer —
check name, approval link, and follow-up issue:

## Verification

- [x] PR description includes a `Signed-off-by:` line and every commit
appears as `Verified` in GitHub
- [x] Normal `pre-commit`, `commit-msg`, and `pre-push` hooks passed, or
`npm run check:diff` passed when hooks were skipped or unavailable
- [x] Targeted behavior tests pass for the current change set, or tests
are marked not applicable above — `npx vitest run
test/changelog-docs.test.ts` passed 6/6.
- [ ] Applicable broad gate passed — `npm test` for broad
runtime/test-harness changes; `npm run check` for repo-wide
validation/coverage changes — not applicable to this doc-only entry.
- [x] Quality Gates section completed with required justifications or
waivers
- [x] No secrets, API keys, or credentials committed
- [ ] `npm run docs` builds without warnings (doc changes only) — passed
with 0 errors and 2 pre-existing Fern warnings.
- [x] Doc pages follow the [style
guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md)
(doc changes only)
- [x] New doc pages include SPDX header and frontmatter (new pages only)
— native changelog entries use the required parser-safe MDX SPDX comment
instead of frontmatter.

---
Signed-off-by: Charan Jagwani <cjagwani@nvidia.com>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Documentation**
  * Added release notes for NemoClaw v0.0.85.
* Documented improvements to compatibility, credential handling, setup
validation, recovery workflows, endpoint configuration, gateway
discovery, and runtime validation.
  * Added links to relevant user-guide sections.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: Charan Jagwani <cjagwani@nvidia.com>
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DGX Station][Sandbox] onboard/rebuild fail "invalid dashboardPort" and block registry operations when a dcode sandbox has dashboardPort 0

3 participants