Skip to content

fix(serve): validate in-process serve flags like the CLI - #13133

Closed
bbingz wants to merge 2 commits into
stablyai:mainfrom
bbingz:fix/13006-serve-flag-validation
Closed

bbingz wants to merge 2 commits into
stablyai:mainfrom
bbingz:fix/13006-serve-flag-validation

Conversation

@bbingz

@bbingz bbingz commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Extract getServeOptions to src/main/startup/serve-options.ts and share cross-flag guards with orca serve via src/shared/serve-option-guards.ts.
  • Reject contradictory combinations (--no-pairing + --mobile-pairing, recipe-json without pairing / without --project-root) on the in-process path the same way the CLI does.
  • Reject security-shaped pairing-flag typos (e.g. --no-pairng, --no-paring) so they cannot silently keep pairing on; stop scanning after --.

Fixes #13006

Test plan

  • Unit tests for getServeOptionGuardError / getServeFlagTypoError
  • Unit tests for getServeOptions including CLI-form normalize + typo path
  • Serve Electron flag parity test updated for extracted module
  • oxlint clean
  • Codex review — cleared (only residual note: do not commit .memory/)

Packaged-binary CLI-form serve skipped CLI cross-flag guards and
silently ignored pairing-flag typos, so a misspelled --no-pairing left
pairing enabled. Share the guards, reject security-flag typos by edit
distance, and stop scanning past --.

Fixes stablyai#13006
@coderabbitai

coderabbitai Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7e17884b-ad4b-4915-be6d-9331e088cb44

📥 Commits

Reviewing files that changed from the base of the PR and between 5783150 and a83d5e4.

📒 Files selected for processing (2)
  • src/main/startup/serve-options.test.ts
  • src/main/startup/serve-options.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/startup/serve-options.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

Serve-option parsing now resides in src/main/startup/serve-options.ts and accepts argv explicitly. Shared guards validate conflicting options, project roots, recognized flags, and likely flag typos. The CLI handler uses the shared validation helper. Startup imports the centralized parser and ServeOptions type. Tests cover parsing, validation, typo detection, option terminators, and Chromium switches.

Merge Risk: ⚪ Minimal · up to a83d5

The PR tightens serve-flag validation and keeps in-process behavior aligned with the CLI; no concrete user or production risk requiring a merge hold is identified, so it is merge-ready after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.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
Title check ✅ Passed The title clearly identifies the main change: validating in-process serve flags consistently with the CLI.
Description check ✅ Passed The description explains the changes, rationale, linked issue, and test coverage, but it does not follow all template headings or checklist sections.
Linked Issues check ✅ Passed The changes address all coding objectives in issue #13006, including typo detection, cross-flag guards, project-root validation, and terminator handling.
Out of Scope Changes check ✅ Passed The implementation and tests remain focused on extracting serve-option parsing and aligning in-process validation with the CLI requirements.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 68d35a77-3243-4191-af75-e838ff74585b

📥 Commits

Reviewing files that changed from the base of the PR and between bba32bd and 5783150.

📒 Files selected for processing (7)
  • src/cli/handlers/core.ts
  • src/cli/serve-electron-flag-parity.test.ts
  • src/main/index.ts
  • src/main/startup/serve-options.test.ts
  • src/main/startup/serve-options.ts
  • src/shared/serve-option-guards.test.ts
  • src/shared/serve-option-guards.ts

Comment thread src/main/startup/serve-options.ts Resolved
Comment thread src/main/startup/serve-options.ts Resolved
@bbingz

bbingz commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded by merged #17683. Current main shares serve option validation across the CLI and in-process entry point, covering incompatible pairing/recipe flags, pairing-flag typos, and the -- terminator. The focused serve validation and Electron flag-parity suites pass.

Verified against main bba68b1bddf1276c8bd27ad4ca41efcbd4260321, with independent Cursor review. Keeping the branch. If the original scenario still reproduces on current main, please share a minimal reproduction so this can be reopened or followed up narrowly.

@bbingz bbingz closed this Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In-process CLI-form serve skips the CLI's flag validation and cross-flag guards

4 participants