Skip to content

Conversation

@LiviaMedeiros
Copy link
Member

Having to fill pr-url in docs is sometimes annoying, since there's no guaranteed way to predict the PR number before pushing the changes.
This PR adds tool that searches for https://github.com/nodejs/node/pull/FILLME and posts https://github.com/nodejs/node/pull/12345 (where 12345 is actual PR number) as code review suggestion (```suggestion).
To avoid unnecessary flooding, it triggers only on initial open, and only if pr-url was explicitly set as https://github.com/nodejs/node/pull/FILLME in the files.

This also could be addressed as local tool, or even as ncu feature (e.g. git node i-feel-lucky to guess the next number, fill and commit).

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/actions

@nodejs-github-bot nodejs-github-bot added meta Issues and PRs related to the general management of the project. tools Issues and PRs related to the tools directory. labels Jan 1, 2026
Comment on lines 27 to 30
const res = await fetch(
new URL(`repos/${REPO}/pulls/${PR_NUMBER}/files`, 'https://api.github.com'),
{ headers },
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to use octokit here, rather than manually interacting with the API?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with either way, by default manual requests should have slightly less overhead. Are there benefits from using octikit here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there benefits from using octikit here?

Primarily that if the API structure changes, Octokit will adjust accordingly without the need for us to make any manual changes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We pass the X-GitHub-Api-Version header, I think worrying about breaking changes is premature here. On the other hand, introducing Octokit seems like increasing maintenance burden and supply chain surface attack.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In terms of potential API changes, i'm still gravitating towards direct fetch. The tool relies on .patch having specific formatting without unified patch headers, so we can't blindly allow switching to future API versions. And after API changes come and v2022-11-28 becomes legacy, it's more likely to be dropped from libraries earlier than from API itself.

LiviaMedeiros and others added 2 commits January 2, 2026 17:57
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Copy link
Member

@avivkeller avivkeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull_request trigger can't access secrets from fork PRs.

node-version: latest
- run: ./tools/actions/suggest-fill-prurl.mjs
env:
GH_TOKEN: ${{ secrets.GH_USER_TOKEN }}
Copy link
Contributor

@aduh95 aduh95 Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GH_TOKEN: ${{ secrets.GH_USER_TOKEN }}
GH_TOKEN: ${{ github.token }}

Copy link
Member

@avivkeller avivkeller Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even so, fork PR tokens don't have the necessary access. I'd recommend changing the trigger to pull_request_target (with all security precautions needed)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 on pull_request_target, it's simply not worth it. Why wouldn't a fork have permission to comment on a PR on a public repo?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why wouldn't a fork have permission to comment on a PR on a public repo?

commenting on a PR requires pull-requests: write permissions, which fork PRs are not granted on the pull_request trigger

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ the suggestion: i used GH_USER_TOKEN specifically to make it posted from @nodejs-github-bot, is this wrong?

@ the pull_request_target: last time i've checked, using

on:
  pull_request:
permissions:
  pull-requests: write

allowed posting a PR comment. But not 100% sure if it was from fork or in a PR within same repo.
I'll try to test this properly in https://github.com/nodejs/node-auto-test. Would it be okay to sync its main first and overwrite nodejs/node-auto-test@f15bbc9?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nobody should be using nodejs/node-auto-test as upstream, so you have free reign for force-pushing its branches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meta Issues and PRs related to the general management of the project. tools Issues and PRs related to the tools directory.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants