[PR #7156] [CLOSED] fix(cli): validate environment-serve --port as decimal text #7682

Closed
opened 2026-11-03 13:39:36 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/7156
Author: @surajvelip
Created: 10/25/2026
Status: ❌ Closed

Base: main ← Head: env-serve-port-validation


📝 Commits (1)

  • d130425 Validate environment-serve --port as decimal text

📊 Changes

1 file changed (+3 additions, -6 deletions)

View changed files

📝 src/cli/environmentCommands.ts (+3 -6)

📄 Description

Summary

Fixes #7093 — environment-serve --port accepted empty or non-decimal values and silently served on another port.

Problem and expected behavior

--port= (e.g. an unset $PORT) parsed as 0 and served on an ephemeral port; --port=0x1F90 parsed as 8080. The flag should reject anything that is not a decimal integer in 0-65535, like MCP_PORT already does.

Change and scope

The port option now uses the shared mcpHttpPortSchema (decimal-text regex, 0-65535) instead of z.number(), which coerced "" to 0 and accepted hex. No behavior change for valid decimal ports.

Contract and boundary impact

  • Semantic owner and earliest changed stage: CLI option schema at environment-serve registration
  • Contribution scope fit and linked maintainer decision: not applicable, ordinary fix inside existing validation boundaries
  • CLI and MCP/tool-catalog contract: --port now rejects empty/non-decimal input instead of coercing
  • Provider, bridge, target-format, or platform compatibility: none
  • Evidence, artifact, provenance, or reconstruction contract: none
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): none
  • Generated metadata, package, or installation impact: none

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: none; the decimal schema is already exercised through MCP_PORT parsing in src/main/mcpHttpArguments.ts
  • Base reproduction or other evidence: source-derived from the issue report and the schema used by the flag before this change
  • User-visible CLI/MCP output (if applicable): invalid --port values now fail option validation instead of serving on a different port
  • Remaining proof gaps: no end-to-end environment-serve invocation run

Validation performed

  • npm run check:fast — typecheck and lint pass

Compatibility, safety, and release

  • Breaking changes or migration steps: none; previously valid decimal input unchanged
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable
  • Package or release metadata impact: none
  • Security, privacy, process, or containment review: stricter input validation only

Author readiness

Human owner: @surajvelip

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/7156 **Author:** [@surajvelip](https://github.com/surajvelip) **Created:** 10/25/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `env-serve-port-validation` --- ### 📝 Commits (1) - [`d130425`](https://github.com/morluto/rea/commit/d1304252033634f1f554a5e827d83509db261c5a) Validate environment-serve --port as decimal text ### 📊 Changes **1 file changed** (+3 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `src/cli/environmentCommands.ts` (+3 -6) </details> ### 📄 Description ## Summary Fixes #7093 — `environment-serve --port` accepted empty or non-decimal values and silently served on another port. ## Problem and expected behavior `--port=` (e.g. an unset `$PORT`) parsed as `0` and served on an ephemeral port; `--port=0x1F90` parsed as 8080. The flag should reject anything that is not a decimal integer in 0-65535, like `MCP_PORT` already does. ## Change and scope The `port` option now uses the shared `mcpHttpPortSchema` (decimal-text regex, 0-65535) instead of `z.number()`, which coerced `""` to `0` and accepted hex. No behavior change for valid decimal ports. ## Contract and boundary impact - Semantic owner and earliest changed stage: CLI option schema at `environment-serve` registration - Contribution scope fit and linked maintainer decision: not applicable, ordinary fix inside existing validation boundaries - CLI and MCP/tool-catalog contract: `--port` now rejects empty/non-decimal input instead of coercing - Provider, bridge, target-format, or platform compatibility: none - Evidence, artifact, provenance, or reconstruction contract: none - Target selection, authority, upstream behavior, and cleanup details (if applicable): none - Generated metadata, package, or installation impact: none Expected effects: - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: none; the decimal schema is already exercised through `MCP_PORT` parsing in `src/main/mcpHttpArguments.ts` - Base reproduction or other evidence: source-derived from the issue report and the schema used by the flag before this change - User-visible CLI/MCP output (if applicable): invalid `--port` values now fail option validation instead of serving on a different port - Remaining proof gaps: no end-to-end `environment-serve` invocation run ## Validation performed - `npm run check:fast` — typecheck and lint pass ## Compatibility, safety, and release - Breaking changes or migration steps: none; previously valid decimal input unchanged - Real Hopper/Ghidra, browser, or OS coverage: not applicable - Package or release metadata impact: none - Security, privacy, process, or containment review: stricter input validation only ## Author readiness Human owner: @surajvelip - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [ ] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 13:39:36 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#7682
No description provided.