Skip to content

fix(opencode): accept leading # in opencode pr <number>#32261

Closed
JSap0914 wants to merge 1 commit into
anomalyco:devfrom
JSap0914:fix/32251-pr-number-hash
Closed

fix(opencode): accept leading # in opencode pr <number>#32261
JSap0914 wants to merge 1 commit into
anomalyco:devfrom
JSap0914:fix/32251-pr-number-hash

Conversation

@JSap0914

Copy link
Copy Markdown

Fixes #32251

opencode pr #992 printed Fetching and checking out PR #NaN and failed, because the number positional is typed number so yargs coerces #992 to NaN. gh pr checkout accepts a leading #, so opencode pr should too.

This types the positional as a string and adds parsePrNumber, which strips one optional leading #, accepts a positive integer, and fails with a clear message otherwise. opencode pr 992 and opencode pr #992 now both resolve to 992.

How I verified

  • Added packages/opencode/test/cli/cmd/pr.test.ts covering bare, #-prefixed, and whitespace input plus rejected cases (#, empty, non-numeric, 0, negative, decimal, double-#).
  • bun test test/cli/cmd/pr.test.ts → 4 pass.
  • bun run typecheck passes; oxlint reports no new findings.

`opencode pr anomalyco#992` printed "Fetching and checking out PR #NaN" and
failed because the `number` positional is typed `number`, so yargs
coerces `anomalyco#992` to NaN. `gh pr checkout` accepts a leading `#`, so
opencode should too.

Type the positional as a string and parse it with `parsePrNumber`,
which strips one optional leading `#`, accepts a positive integer, and
fails with a clear message otherwise.
Copilot AI review requested due to automatic review settings June 14, 2026 03:38
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jun 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

Copilot AI 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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds robust parsing/validation for PR numbers in the pr CLI command (including #123 and whitespace), and verifies behavior with new tests.

Changes:

  • Introduced parsePrNumber() helper to normalize and validate PR number input.
  • Updated pr command argument type from number to string and added a validation failure path.
  • Added Bun tests covering accepted/rejected PR number formats.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/opencode/test/cli/cmd/pr.test.ts Adds unit tests for PR number parsing behavior.
packages/opencode/src/cli/cmd/pr.ts Implements PR number parsing/validation and updates CLI arg handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const prNumber = args.number
const prNumber = parsePrNumber(args.number)
if (prNumber === undefined) {
return yield* fail(`Invalid PR number: ${args.number}. Pass a positive integer, optionally prefixed with '#'.`)
Comment on lines +20 to 22
type: "string",
describe: "PR number to checkout",
demandOption: true,
Comment on lines +18 to +27
test("rejects non-numeric, empty, zero, negative, decimal, and double-hash input", () => {
expect(parsePrNumber("#")).toBeUndefined()
expect(parsePrNumber("")).toBeUndefined()
expect(parsePrNumber("abc")).toBeUndefined()
expect(parsePrNumber("0")).toBeUndefined()
expect(parsePrNumber("-3")).toBeUndefined()
expect(parsePrNumber("12.5")).toBeUndefined()
expect(parsePrNumber("99x")).toBeUndefined()
expect(parsePrNumber("##992")).toBeUndefined()
})
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jun 14, 2026
@github-actions github-actions Bot closed this Jun 14, 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.

opencode pr #<number> parses PR number as NaN

2 participants