labeler: starter-workflow template gives `Resource not accessible by integration`
Hi there,
I’ve implemented the exact Labeler workflow as the starter-workflow template in the dir path .github/workflows/label.yml
.
I have also added the .github/labeler.yml
file with the configuration below:
Trader: packages/trader/**/*
Bot: packages/bot/**/*
Core: packages/core/**/*
Components: packages/components/**/*
Shared: packages/shared/**/*
The action is recognised and runs on PR, however the Labeler action resolves with the following error:
##[error]HttpError: Resource not accessible by integration
##[error]Resource not accessible by integration
##[error]Node run failed with exit code 1
Googling seems to relate that error with invalid access to the repo by the action app, so I thought I’d create an issue and disable the action for now, but would be happy to know if there’s something I have missed out that will be able to solve this issue for me.
Thanks.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 47
- Comments: 80 (21 by maintainers)
Commits related to this issue
- Run labeler action on cron. See https://github.com/actions/labeler/issues/12#issuecomment-525762657 — committed to canonical/maas-ui by squidsoup 5 years ago
- Use cron triggers — committed to actions/labeler by deleted user 5 years ago
- disable labeler temporarily Disable the workflow until a solution to actions/labeler#12 has been found. After the linked issue has been solved, we probably need to also bump the version of the act... — committed to exercism/website-copy by NobbZ 5 years ago
- delete auto labeler doesn't work on forks : actions/labeler#12 — committed to SubhrajitPrusty/wallgen by SubhrajitPrusty 5 years ago
- Delete label.yml doesn't work on forks : actions/labeler#12 — committed to SubhrajitPrusty/codex-github by SubhrajitPrusty 5 years ago
- Delete label.yml doesn't work on forks : actions/labeler#12 — committed to SubhrajitPrusty/ycl by SubhrajitPrusty 5 years ago
- Avoid labeling external PRs Doing this to avoid a long-standing bug in GitHub labeler action, which results in failure for the labeler for PRs from forks: https://github.com/actions/labeler/issues/12 — committed to dotnet/aspnetcore by mkArtakMSFT 5 years ago
- Disable labeler for now since it doesn't work with PRs opened from forks See https://github.com/actions/labeler/issues/12#issuecomment-525762657 for more info. — committed to wesnoth/wesnoth by Vultraz 5 years ago
- Avoid labeling external PRs (#15171) Doing this to avoid a long-standing bug in GitHub labeler action, which results in failure for the labeler for PRs from forks: https://github.com/actions/labeler/... — committed to dotnet/aspnetcore by mkArtakMSFT 5 years ago
- automation: avoid labeling external PRs Doing this to avoid a long-standing bug in GitHub labeler action, which results in failure for the labeler for PRs from forks: https://github.com/actions/label... — committed to unoplatform/uno by ghuntley 5 years ago
- automation: avoid labeling external PRs (#1909) Doing this to avoid a long-standing bug in GitHub labeler action, which results in failure for the labeler for PRs from forks: https://github.com/actio... — committed to unoplatform/uno by ghuntley 5 years ago
- Avoid labeling external PRs (#15171) Doing this to avoid a long-standing bug in GitHub labeler action, which results in failure for the labeler for PRs from forks: https://github.com/actions/labeler/... — committed to InDieTasten/AspNetCore by mkArtakMSFT 5 years ago
- disable label action for now it just does not work for forks - https://github.com/actions/labeler/issues/12 — committed to oracle/opengrok by deleted user 5 years ago
- Avoid labeling external PRs ref: https://github.com/actions/labeler/issues/12 — committed to nodejs/nodejs-ko by marocchino 5 years ago
- chore(github): disable labeler Disabled until fix for https://github.com/actions/labeler/issues/12 is present — committed to react-grid-layout/react-grid-layout by STRML 5 years ago
- Disable labeler Currently Labeler isn't useful for us. It doesn't work on PRs from forks, see https://github.com/actions/labeler/issues/12 Using "on: schedule" instead of "on: pull_request" creates j... — committed to mueller-ma/openhab.android by mueller-ma 5 years ago
- Disable labeler (#1680) Currently Labeler isn't useful for us. It doesn't work on PRs from forks, see https://github.com/actions/labeler/issues/12 Using "on: schedule" instead of "on: pull_request" ... — committed to openhab/openhab-android by mueller-ma 5 years ago
- fix(github): use periodic-labeler to fix https://github.com/actions/labeler/issues/12 — committed to react-grid-layout/react-grid-layout by STRML 5 years ago
- Switch labeler to periodic-labeler With https://github.com/actions/labeler/issues/12 being an issue, the action's labeler is useless for PRs that come from a fork. This one runs on a cron timer ins... — committed to radareorg/radare2 by GustavoLCR 5 years ago
- Switch labeler to periodic-labeler (#15517) With https://github.com/actions/labeler/issues/12 being an issue, the action's labeler is useless for PRs that come from a fork. This one runs on a cron ... — committed to radareorg/radare2 by GustavoLCR 5 years ago
What is the end solution?
tl;dr, change
to
GitHub has introduced a new event type:
pull_request_target
, which allows to run workflows from base branch and pass a token with write permission.Since this action doesn’t work for a lot of users including me, I created some sort of alternative at https://github.com/marketplace/actions/periodic-labeler. This isn’t anything fancy and the workaround is to just run it periodically from master branch. Configuration is the same as in action located here, so migration should be simple. I am already using it in @cloudalchemy org.
Apparently, GitHub is treating dependabot prs like forks. Here is the related article. As @TobKed has suggested, I used the following snippet on the top level of my workflow to grant the needed permissions. So thank you very much.
Additional question to @TobKed assuming that the repository will always be private and I will only use dependabot to update private submodules that my repository is dependent to, do you think it is also possible/safe to use
pull_request_target
as my event trigger without adding any permissions like you have suggested?Hello @damccorm, Is there any way or workaround to trigger the action on the base repository so that the GitHub Action token will have both read/write access when there is a PR from the forked repository. And there is no need to re-write the whole code base.
@damccorm option 2 certainly sounds far more useful for us - our workflow has every developer on our project making PRs from their forks (and presumably that’s a fairly common workflow).
Hm, so it looks like this is an issue with forks: works fine on my branch fails on fork
I’ll reach out internally and figure out if that’s expected scoping of permissions for the GITHUB_TOKEN and we can go from there
Yeah, believe me you’re not the only one having a solid WTF moment.
I’m completely okay with forks having the ability to apply labels and no ability to do anything else like create labels or any other write action. If someone abuses applying labels then I’ll ban them.
I have created a Github app (based on Probot) that takes similar configurations and does the same job and works for Forked PRs too.
More information: https://github.com/kaxil/boring-cyborg App Page: https://github.com/apps/boring-cyborg
We are already using it on Apache Airflow repo.
Indeed. We’ll take a closer look at this for sure; I just wanted to explain why it’s not trivial and something that we want to make sure that we get right when we do.
I’m experiencing this in an enterprise repo with PRs opened by dependabot. As far as I can tell, dependabot creates a branch, not a fork. Is there a proper/secure way to get this action to work for dependabot PRs?
@potiuk I suggest you read the comment I wrote on GitHub Community, it explains it all 😄
I’ll have to respectfully disagree. PRs should at the very least be able to act on themselves…
Could someone please reopen this? I know the “bug” doesn’t come from actions/labeler itself, but this is such a major limitation that someone at GitHub should find a way to make this work!!
Seriously, having running actions from forks in a read-only environment makes actions pretty much useless! You can’t run any kind of CI / lint / action really. Well, you can, but you cannot report it within the PR itself, which makes the entire thing pointless!
@ethomson Thank you very much for the detailed response. I totally agree that read/write access should not be given for the PR to all the actions for security reasons.
My proposal would be to have a flag for the repository admin to enable read/write access only to the trusted actions. This issue is raised multiple times in the GitHub Community Forum.
We’ve enabled this for our repository too and are facing the same issue. Would be good to at least define some way to handle this in the workflow, so we can customize the logic. Of course the best option would be to support what was already suggested by @ibakshay:
Option 1 makes this action useless, as whoever who has write access can put the labels themselves as necessary, though in a repo with 90 percent or more contribution through forks, we really wanted to use this action to reduce manual work.
Why can’t you just use the default branches labeler.yml as canonical config?
@dgokcin it is possible to use
pull_request_target
(actually I started to use it like that in my private repositories recently). Is it safe? I think yes, but I am not 100% sure about that. If it is related to some critical code I would suggest consultations with security specialists 😃I am also having the same issue on the PRs opened by dependabot. The problematic action is supposed to generate a test report and update the check statuses. Any ideas for a workaround?
Also @igor-petrik-invitae were you able to figure out a way to make the actions work with dependabot?
@OndroMih
This may be unsecure, PTAL at Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests
It was solved in another, more secure way (different action used, bur rule is the same) in https://github.com/apache/incubator-doris/ and https://github.com/apache/airflow. PTAL on usage:
I’m having this issue after transferring a repository to an organisation, no forks
I’m not sure we’re saying exactly the same thing. I don’t want to be too explicit about what the problem is here exactly - or how it needs to be fixed, but there is a big problem with Actions (for many people).
GitHub actions if they are not incredibly broken (seems perhaps they are working as designed) then they are at the very least marketed and misrepresented horribly by GitHub. I wish I had back the hour or two I wasted trying to do anything useful with Actions on a OSS project. I’m sure they are working for someone, but I wish GitHub would write better docs and market them in a more responsible fashion.
It seems GitHub knows enough about a project (based on all the other info it provides the admin) that it could make better choices about suggesting someone use these tools if there was zero chance they were going to fit the workflow in question. @Ecco I feel your pain.
@Toflar The problem is this is a SUPER common use case - I assumed the whole reason this workflow was listed so prominently was FOR this exact use case - and the docs say nothing to the contrary. Can we please merge #50? That would have saved me like an hour of time.
@ethomson
Thanks everybody for the commentary, I appreciate that this isn’t helpful for many of your workflows. We’re investigating some changes to token permissions to help enable fork-based workflows, but I don’t have an ETA on that.
We’ll make some changes to this to make it easier to use, but given the security impact, we’re analyzing this carefully.
The token is still read-only, no matter how you use it. Its ability to be exfiltrated is why we’ve made it read-only for forks.
Workflows are run in the context “of the repository”. But when any workflow is run because a pull request triggered it, then the token is downgraded to a read-only token.
It’s not “the fork’s token”, it’s still the repository’s token, it’s just read-only.
This is intentional. It’s so that somebody can’t open a pull request that gives them a token that they could use to write to your repository.
We’ll continue to investigate workarounds, but the security model here is important to keep in mind.
Yeah, agreed option 2 makes a lot more sense.
The issue isn’t getting the
labeler.yml
, the issue here is that workflows that run on forks don’t have write permissions (so they can’t create labels)I spoke too soon. Switching this to cron by itself won’t work because we assume its going to be run on a PR. Trying to figure out what makes the most sense here. Option 1 is to just not add labels to forks (but we shouldn’t throw like we do now regardless). Option 2 is to update it to filter through all pull requests.
In theory I like option 2, but we need to be careful or we’ll get rate limited - along those lines, we need a way of skipping PRs that we’ve already processed - maybe we could add a “triaged” label or something, but that’s kind of ugly.
Thoughts? My instinct is to start with option 1 - better error handling on forks - and then move on to option 2 as appropriate
Thanks for investigating, @damccorm. And the update seems like a good alternative for my use at least. Others can reopen this if necessary, but I’ll close it as it’s expected behavior.
Just pinging you, @squidsoup to loop you in.
It looks like a solution is to trigger the action on the pull_request_target event instead of the
pull-request
event.I see that the README is now updated to use the
pull_request_target
event. I just wanted to comment about it also here because Github’s template still usespull_request
and it might be useful to people that search for a solution and they come across this page.This issue appears as closed but the error still happens, any hint?
@yyyc514 Would you mind upvoting my comment on GitHub community to try and raise awareness about this? Thanks 😄
You can see from this issue only on how many users are affected because of this limitation from GitHub Actions 😞.
@ethomson what you said is all correct. But let’s try a possible solution
One who wants updates workflow normally has write access to the repository, so he can make a pull request from the same repo.
If workflow would uses a version from the target branch, then as I said it eliminates most security concerns. But in some cases, a malicious person can hack the system by changing other files in repo (e.g. when workflow calls other scripts from the repo). A solution for this scenario could be an option in settings to restrict access in a forked pull request (i.e. as it works now) or adding new setting to specify which files have to be secured and modified version of those files must not be used in workflows of forked pull requests
I don’t understand why there’s a WTF moment? This action was created trying to implement exactly this functionality but it’s currently not possible because of how tokens work in GitHub Actions. There’s absolutely nothing hard about this to understand^^
When a workflow runs on a pull request event, the workflow run gets a read only token to the main repository. This is so that somebody can’t fork your repository and maliciously write to your code, create harmful issues or exfiltrate tokens. Or - I’m afraid - add labels to issues. The token is explicitly read only for security.
We’re considering some other alternatives here, but at the moment, this will not work with PRs from forks.
No, it’s not about your permissions. The GITHUB_TOKEN has a writable token for the repository. It’s about whether you’re opening a PR from a fork, or whether you’re opening a PR directly in the repository.
The PR from a fork does not have a writable token and will fail. The PR from a repository will succeed since the GITHUB_TOKEN has write permissions.
Same problem when you try to create a comment to an issue. Which shouldn’t be a problem, since anyone can do that, right?
I just submitted a support ticket about this, but probably should have checked here first! thanks @damccorm