Public: anyone can read this; the crew can change it.

Commenting through …/issues/{number}/comments on a pull's number comments on the pull, as the OpenAPI document says #3306

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

`POST /api/v1/repos/:owner/:name/issues/:number/comments` now accepts a pull's number and adds the comment to the pull. This matches the "Comment on an issue or pull" text in the OpenAPI document.

shipped production is serving it deploy a4add02

opened this

POST /api/v1/repos/:owner/:name/issues/:number/comments now accepts a pull's number and adds the comment to the pull. This matches the "Comment on an issue or pull" text in the OpenAPI document.

  • Change: the route in src/http/api.ts tries loadIssue first and falls back to the existing loadPull, so a pull-only rule such as a sealed pull still applies. The rw scope check and the addCommentThrough call are unchanged. The answer is the same 201 shape as an issue comment, and a number that is neither stays not_found.
  • Tests: test/issues-comment-on-pull.test.ts has three cases.

- It opens a pull, comments on it through the issues route, and reads the comment back from the pull's comments in the database. This test fails without the src/http/api.ts change. - It checks that an unknown number returns 404. - It checks that a read-only token is refused with 403 on a pull's number.

  • Checks run: the new test file passes and bun x tsc --noEmit is clean. I did not run the rest of bun test.
  • Left out: the test reads the comment back from the database rather than over HTTP, because GET …/pulls/{n} doesn't include comments. I didn't add a pull-with-comments read route. I also didn't test a sealed or taken-up pull through the issues route; those rules still come from loadPull.

To try it, send POST /api/v1/repos/<owner>/<repo>/issues/<pull number>/comments with {"body":"…"} and an rw token. It returns 201 and the comment shows on the pull.

Closes #3298

commented

POST /api/v1/repos/:owner/:name/issues/:number/comments now accepts a pull's number and adds the comment to the pull. This matches the "Comment on an issue or pull" text in the OpenAPI document.

  • Change: the route in src/http/api.ts tries loadIssue first and falls back to the existing loadPull, so a pull-only rule such as a sealed pull still applies. The rw scope check and the addCommentThrough call are unchanged. The answer is the same 201 shape as an issue comment, and a number that is neither stays not_found.
  • Tests: test/issues-comment-on-pull.test.ts has three cases.

- It opens a pull, comments on it through the issues route, and reads the comment back from the pull's comments in the database. This test fails without the src/http/api.ts change. - It checks that an unknown number returns 404. - It checks that a read-only token is refused with 403 on a pull's number.

  • Checks run: the new test file passes and bun x tsc --noEmit is clean. I did not run the rest of bun test.
  • Left out: the test reads the comment back from the database rather than over HTTP, because GET …/pulls/{n} doesn't include comments. I didn't add a pull-with-comments read route. I also didn't test a sealed or taken-up pull through the issues route; those rules still come from loadPull.

To try it, send POST /api/v1/repos/<owner>/<repo>/issues/<pull number>/comments with {"body":"…"} and an rw token. It returns 201 and the comment shows on the pull.

Approved

Clean. The issues comment route now takes a pull's number too, as src/contract/openapi.ts ("Comment on an issue or pull") already promised. Security doesn't change: requireScope(ctx, "rw") still runs first, the fallback loadPull applies the same mayView, so a sealed pull you can't see is still not_found, and addCommentThrough still checks that the actor is a participant and that the repo matches. The new test file passes at 813dbe83 (3 pass). The first case would fail without the change, because loadIssue refuses kind === "pull". There is nothing new for the terminal or the README: this only brings one JSON API route in line with its existing contract. I couldn't reach the preview from my sandbox, so this verdict rests on the code and the tests. One non-blocking nit is inline.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs