Skip to content

fix(cli): honor port 0 in checkPortAvailable - #1304

Merged
cv merged 7 commits into
NVIDIA:mainfrom
ChunkyMonkey11:fix/preflight-port-zero
Apr 3, 2026
Merged

fix(cli): honor port 0 in checkPortAvailable#1304
cv merged 7 commits into
NVIDIA:mainfrom
ChunkyMonkey11:fix/preflight-port-zero

Conversation

@ChunkyMonkey11

@ChunkyMonkey11 ChunkyMonkey11 commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR fixes a bug in CLI preflight port handling by preserving port = 0 instead of incorrectly defaulting it to 18789.
In Node.js networking, 0 is a valid value that asks the OS to assign a temporary available port.
The fix changes null/default logic to keep valid explicit inputs while still applying the default when no port is provided.

Changes

  • Updated checkPortAvailable in src/lib/preflight.ts:
    • Before: const p = port || 18789;
    • After: const p = port ?? 18789;
  • This preserves:
    • undefined/null -> default 18789
    • 0 -> stays 0 (valid OS-assigned temporary available port request)
    • any explicit non-null value -> unchanged
  • No CLI command surface changes.
  • No docs changes required.

Type of Change

  • Code change for a new feature, bug fix, or refactor.
  • Code change with doc updates.
  • Doc only. Prose changes without code sample modifications.
  • Doc only. Includes code sample changes.

Testing

  • npx prek run --all-files passes (or equivalently make check).
  • npm test passes.
  • make docs builds without warnings. (for doc-only changes)

Checklist

General

Code Changes

  • Formatters applied — npx prek run --all-files auto-fixes formatting (or make format for targeted runs).
  • Tests added or updated for new or changed behavior.
  • No secrets, API keys, or credentials committed.
  • Doc pages updated for any user-facing behavior changes (new commands, changed defaults, new features, bug fixes that contradict existing docs).

Doc Changes

  • Follows the style guide. Try running the update-docs agent skill to draft changes while complying with the style guide. For example, prompt your agent with "/update-docs catch up the docs for the new changes I made in this PR."
  • New pages include SPDX license header and frontmatter, if creating a new page.
  • Cross-references and links verified.

Signed-off-by: Revant Patel revant.h.patel@gmail.com

Summary by CodeRabbit

  • Bug Fixes
    • Corrected port configuration handling to properly respect explicitly set values instead of defaulting to the standard port.

@coderabbitai

coderabbitai Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The checkPortAvailable() function in src/lib/preflight.ts was updated to use nullish-coalescing (??) instead of logical-or (||) when defaulting the port parameter. This preserves an explicitly provided port value of 0 instead of replacing it with the default port 18789.

Changes

Cohort / File(s) Summary
Port defaulting logic
src/lib/preflight.ts
Changed port parameter handling from logical-or to nullish-coalescing operator to preserve explicit port value of 0 instead of replacing it with the default.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

A rabbit hops through code so small,
One operator fixes all!
From \|\| to ?? it goes,
Port zero now survives the flows! 🐰✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main change: using nullish coalescing to preserve port 0 instead of replacing it with the default 18789.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

@ChunkyMonkey11

Copy link
Copy Markdown
Contributor Author

@cv I fixed the PR issue and this should be good now. Updated the PR body sign-off format, and checks are now passing on my side (npx prek run --all-files, npm test, make docs). Please take another look when you have a moment.

@cv
cv enabled auto-merge (squash) April 2, 2026 21:53
@ChunkyMonkey11

Copy link
Copy Markdown
Contributor Author

@cv I see that you enabled auto merge I am still getting this workflow requires approval from a maintainer. Please take another look when you have a moment.

@ChunkyMonkey11
ChunkyMonkey11 requested a review from cv April 3, 2026 04:49
@cv
cv merged commit 743b288 into NVIDIA:main Apr 3, 2026
4 checks passed
quanticsoul4772 added a commit to quanticsoul4772/NemoClaw that referenced this pull request Apr 4, 2026
…ions API

Two upstream bug fixes backported from NVIDIA/NemoClaw:
- preflight.js: `port || 18789` → `port ?? 18789` so port=0 (OS-assigned)
  is not incorrectly replaced by the default (upstream NVIDIA#1304)
- onboard.js: Force openai-completions for Ollama regardless of probe result.
  Ollama 0.19.0 /v1/responses endpoint passes probe but produces malformed
  tool calls in the TUI. Matches existing vLLM/NIM override pattern.
  Update test assertion that was asserting the buggy value (upstream NVIDIA#1315)
lakamsani pushed a commit to lakamsani/NemoClaw that referenced this pull request Apr 4, 2026
<!-- markdownlint-disable MD041 -->
## Summary

This PR fixes a bug in CLI preflight port handling by preserving `port =
0` instead of incorrectly defaulting it to `18789`.
In Node.js networking, `0` is a valid value that asks the OS to assign a
temporary available port.
The fix changes null/default logic to keep valid explicit inputs while
still applying the default when no port is provided.

## Changes

- Updated `checkPortAvailable` in `src/lib/preflight.ts`:
  - Before: `const p = port || 18789;`
  - After: `const p = port ?? 18789;`
- This preserves:
  - `undefined`/`null` -> default `18789`
- `0` -> stays `0` (valid OS-assigned temporary available port request)
  - any explicit non-null value -> unchanged
- No CLI command surface changes.
- No docs changes required.

## Type of Change

- [x] Code change for a new feature, bug fix, or refactor.
- [ ] Code change with doc updates.
- [ ] Doc only. Prose changes without code sample modifications.
- [ ] Doc only. Includes code sample changes.

## Testing

- [x] `npx prek run --all-files` passes (or equivalently `make check`).
- [x] `npm test` passes.
- [x] `make docs` builds without warnings. (for doc-only changes)

## Checklist

### General

- [x] I have read and followed the [contributing
guide](https://github.com/NVIDIA/NemoClaw/blob/main/CONTRIBUTING.md).
- [ ] I have read and followed the [style
guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md).
(for doc-only changes)

### Code Changes

- [x] Formatters applied — `npx prek run --all-files` auto-fixes
formatting (or `make format` for targeted runs).
- [x] Tests added or updated for new or changed behavior.
- [x] No secrets, API keys, or credentials committed.
- [x] Doc pages updated for any user-facing behavior changes (new
commands, changed defaults, new features, bug fixes that contradict
existing docs).

### Doc Changes

- [ ] Follows the [style
guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md).
Try running the `update-docs` agent skill to draft changes while
complying with the style guide. For example, prompt your agent with
"`/update-docs` catch up the docs for the new changes I made in this
PR."
- [ ] New pages include SPDX license header and frontmatter, if creating
a new page.
- [ ] Cross-references and links verified.

---
Signed-off-by: Revant Patel <revant.h.patel@gmail.com>



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

## Summary by CodeRabbit

* **Bug Fixes**
* Corrected port configuration handling to properly respect explicitly
set values instead of defaulting to the standard port.

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

---------

Co-authored-by: Carlos Villela <cvillela@nvidia.com>
gemini2026 pushed a commit to gemini2026/NemoClaw that referenced this pull request Apr 14, 2026
<!-- markdownlint-disable MD041 -->
## Summary

This PR fixes a bug in CLI preflight port handling by preserving `port =
0` instead of incorrectly defaulting it to `18789`.
In Node.js networking, `0` is a valid value that asks the OS to assign a
temporary available port.
The fix changes null/default logic to keep valid explicit inputs while
still applying the default when no port is provided.

## Changes

- Updated `checkPortAvailable` in `src/lib/preflight.ts`:
  - Before: `const p = port || 18789;`
  - After: `const p = port ?? 18789;`
- This preserves:
  - `undefined`/`null` -> default `18789`
- `0` -> stays `0` (valid OS-assigned temporary available port request)
  - any explicit non-null value -> unchanged
- No CLI command surface changes.
- No docs changes required.

## Type of Change

- [x] Code change for a new feature, bug fix, or refactor.
- [ ] Code change with doc updates.
- [ ] Doc only. Prose changes without code sample modifications.
- [ ] Doc only. Includes code sample changes.

## Testing

- [x] `npx prek run --all-files` passes (or equivalently `make check`).
- [x] `npm test` passes.
- [x] `make docs` builds without warnings. (for doc-only changes)

## Checklist

### General

- [x] I have read and followed the [contributing
guide](https://github.com/NVIDIA/NemoClaw/blob/main/CONTRIBUTING.md).
- [ ] I have read and followed the [style
guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md).
(for doc-only changes)

### Code Changes

- [x] Formatters applied — `npx prek run --all-files` auto-fixes
formatting (or `make format` for targeted runs).
- [x] Tests added or updated for new or changed behavior.
- [x] No secrets, API keys, or credentials committed.
- [x] Doc pages updated for any user-facing behavior changes (new
commands, changed defaults, new features, bug fixes that contradict
existing docs).

### Doc Changes

- [ ] Follows the [style
guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md).
Try running the `update-docs` agent skill to draft changes while
complying with the style guide. For example, prompt your agent with
"`/update-docs` catch up the docs for the new changes I made in this
PR."
- [ ] New pages include SPDX license header and frontmatter, if creating
a new page.
- [ ] Cross-references and links verified.

---
Signed-off-by: Revant Patel <revant.h.patel@gmail.com>



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

## Summary by CodeRabbit

* **Bug Fixes**
* Corrected port configuration handling to properly respect explicitly
set values instead of defaulting to the standard port.

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

---------

Co-authored-by: Carlos Villela <cvillela@nvidia.com>
@wscurran wscurran added area: cli Command line interface, flags, terminal UX, or output bug-fix PR fixes a bug or regression and removed NemoClaw CLI 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 bug-fix PR fixes a bug or regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants