Skip to content

fix(doctor): use the shared parseRequestTimeoutFlag - #370

Closed
x15967311210-crypto wants to merge 1 commit into
TestSprite:mainfrom
x15967311210-crypto:fix/doctor-shared-request-timeout-flag
Closed

x15967311210-crypto wants to merge 1 commit into
TestSprite:mainfrom
x15967311210-crypto:fix/doctor-shared-request-timeout-flag

Conversation

@x15967311210-crypto

@x15967311210-crypto x15967311210-crypto commented Oct 11, 2026 •

Copy link
Copy Markdown

Season 4 CLI Improvement Bonus

  • I'm entering this PR for the Season 4 CLI Improvement Bonus

Discord username: @rr_1999

What does this PR do?

testsprite doctor carried its own private parseRequestTimeoutFlag, a leftover from before the helper was centralized in src/lib/client-factory.ts. Its VALIDATION_ERROR message had already drifted from the shared one every other command uses, so the same flag input produced a different message depending on the command:

$ testsprite doctor --request-timeout abc
Error: Invalid request.
Flag `--request-timeout` is invalid: must be a positive number of seconds (got "abc").

$ testsprite project list --request-timeout abc
Error: Invalid request.
Flag `--request-timeout` is invalid: "abc" is not valid — must be a positive number of seconds.

This deletes the local copy and imports the shared helper, so the flag reads identically across the CLI. There is no behaviour change beyond the message text — the two implementations were otherwise identical (Number(raw), reject when non-finite or <= 0, Math.round(seconds * 1000)).

Related issue

Closes #364

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that changes existing behavior)
  • Documentation only
  • Build / CI / chore

Checklist

  • PR targets the main branch.
  • Commits follow Conventional Commits (fix(doctor): ...).
  • npm run lint and npm run format:check pass.
  • npm run typecheck passes.
  • npm test passes and coverage stays at or above the 80% gate. (115 files, 4578 passed / 11 skipped, 0 failed)
  • New behavior is covered by unit tests (mock-based; no network or credentials required).
  • No secrets, API keys, internal endpoints, or personal data are included.
  • User-facing changes are reflected in README.md / DOCUMENTATION.md where relevant (message-only unification; no docs surface changes).

Notes for reviewers

The added test pins doctor's message to the shared wording. I checked it is not vacuous: restoring the previous doctor.ts makes the new test fail on the drifted message, and it passes against this change.

The only lint output is a pre-existing unused eslint-disable directive at doctor.test.ts:333, untouched by this PR.

Discord username: @rr_1999

Summary by CodeRabbit

  • Bug Fixes
    • The doctor command now validates request-timeout values consistently. Nonnumeric values are rejected with a clear validation error and the appropriate exit code, rather than being accepted or handled inconsistently. The validation message also specifies that the timeout must be a positive number of seconds.

doctor carried a private copy of parseRequestTimeoutFlag whose error message had already drifted from the shared helper every other command uses. Same flag, same bad input, two different messages.

Delete the copy and import the shared helper, so the timeout flag reads identically across doctor and the rest of the CLI. Adds a wiring test that pins doctor's message to the shared wording.

Refs TestSprite#364
@github-actions

Copy link
Copy Markdown

Thanks for the PR, @x15967311210-crypto! It links an issue, but that issue isn't assigned to you yet: #364 (unassigned). Per our workflow, claim the issue first by commenting /assign on it (the triage bot assigns you automatically). If it's already assigned to someone else, please coordinate with them or pick another issue — unclaimed-issue PRs are not reviewed. After fixing it, edit the PR description or push a commit to re-run this check. See CONTRIBUTING → Contribution model.

@github-actions github-actions Bot added the needs-issue PR not linked to an issue yet — please open one first and claim it (see CONTRIBUTING) label Oct 11, 2026
@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: TestSprite/testsprite-cli/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a8597a69-1dbe-4684-8252-3e22c0fa7ec2

📥 Commits

Reviewing files that changed from the base of the PR and between 988c035 and 3a25177.


📒 Files selected for processing (2)
  • src/commands/doctor.test.ts
  • src/commands/doctor.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.



Walkthrough

The doctor command now uses the shared request-timeout parser. Its command-wiring test verifies that a nonnumeric timeout produces the shared validation error.

Changes

Doctor timeout validation

Layer / File(s) Summary
Use and validate the shared timeout parser
src/commands/doctor.ts, src/commands/doctor.test.ts
The doctor command imports the shared parser and removes its local copy. The test registers the timeout option and checks that abc produces VALIDATION_ERROR, exit code 5, and the positive-seconds validation message.

Priority: ⬇️ Low

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

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 3a251

The timeout parser change preserves existing acceptance, conversion, and error behavior while aligning doctor’s validation wording. No actionable merge risk remains in the reviewed change.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely identifies the main change: replacing doctor’s local request-timeout parser with the shared parseRequestTimeoutFlag helper.
Linked Issues check Passed Issue #364 requires doctor to use the shared parseRequestTimeoutFlag and to align its validation message. src/commands/doctor.ts imports the helper from src/lib/client-factory.js and removes t…
Out of Scope Changes check Passed The changes stay within issue #364. The added test registers the flag in the doctor fixture and verifies the required command behavior. No unrelated source, public API, or documentation changes are sh…

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@github-actions

Copy link
Copy Markdown

🏆 Season 4 CLI Improvement Bonus: entry recorded. Thanks, @x15967311210-crypto!

To be counted, this PR needs the following by Oct 29, 11:59 PM PT:

  • ⬜ A linked issue assigned to you: the issue this PR links isn't assigned to you yet. Claim it by commenting /assign on it.
  • ✅ Out of draft.
  • ✅ A Discord username in the description.

Rewards go to merged PRs judged a genuine improvement, and up to three bonus-eligible PRs count per person. Untick the box to withdraw the entry. This comment refreshes when you edit the PR. Full rules.

@github-actions github-actions Bot added the s4-cli-bonus Entered for the Season 4 CLI Improvement Bonus label Oct 22, 2026
@fyZhang66

Copy link
Copy Markdown
Contributor

Thanks @x15967311210-crypto. Closing along with #364, which we're not taking (wording-only change while the command surface is being rewritten).

@fyZhang66 fyZhang66 closed this Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-issue PR not linked to an issue yet — please open one first and claim it (see CONTRIBUTING) s4-cli-bonus Entered for the Season 4 CLI Improvement Bonus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Hackathon] fix(doctor): use the shared parseRequestTimeoutFlag — local copy's message has drifted

2 participants