Skip to content

FilePusher is failing due to insufficient permissions to edit GitHub Actions workflow files #1410

Closed

Description

@mthalman

This FilePusher run (internal link) is failing with a 404 error for the dotnet-docker main branch:

Microsoft.DotNet.VersionTools.Automation.GitHubApi.HttpFailureResponseException: Response code does not indicate success: 404 (NotFound) with content: {"message":"Not Found","documentation_url":"[https://docs.github.com/rest/git/refs#update-a-reference","status":"404"}](https://docs.github.com/rest/git/refs#update-a-reference%22,%22status%22:%22404%22})
   at Microsoft.DotNet.VersionTools.Automation.GitHubApi.GitHubClient.EnsureSuccessfulAsync(HttpResponseMessage response) in /_/src/VersionTools/Microsoft.DotNet.VersionTools/Automation/GitHubApi/GitHubClient.cs:line 466
   at Microsoft.DotNet.VersionTools.Automation.GitHubApi.GitHubClient.DeserializeSuccessfulAsync[T](HttpResponseMessage response) in /_/src/VersionTools/Microsoft.DotNet.VersionTools/Automation/GitHubApi/GitHubClient.cs:line 440
   at Microsoft.DotNet.VersionTools.Automation.GitHubApi.GitHubClient.PatchReferenceAsync(GitHubProject project, String ref, String sha, Boolean force) in /_/src/VersionTools/Microsoft.DotNet.VersionTools/Automation/GitHubApi/GitHubClient.cs:line 405
   at FilePusher.FilePusher.CreatePullRequestAsync(GitHubClient client, GitRepo gitRepo, Config config, Options options) in /file-pusher/FilePusher.cs:line 154
   at FilePusher.FilePusher.<>c__DisplayClass2_1.<<PushFilesAsync>b__0>d.MoveNext() in /file-pusher/FilePusher.cs:line 61

This is preventing automated roll out of common infrastructure to the product repos.

What's interesting is that it was able to successfully create a PR for the nightly branch: dotnet/dotnet-docker#5827

Activity

  1. self-assigned this
    on Aug 26, 2024
  2. moved this from Backlog to Sprint in .NET Dockeron Aug 26, 2024
  3. mthalman commented on Aug 27, 2024

    @mthalman
    MemberAuthor

    This is failing for the nightly branch now too.

  4. changed the title [-]404 error from FilePusher [/-] [+]FilePusher is failing due to insufficient permissions to edit GitHub Actions workflow files[/+] on Aug 29, 2024
  5. lbussell commented on Aug 29, 2024

    @lbussell
    Member

    The root cause of this issue was enabling GitHub Actions and adding the corresponding workflow files as part of dotnet/dotnet-docker#5316. GitHub workflow files are covered by a separate PAT scope than all other files in the repo. This error was inconsistent because not every PR submitted by the bot edits the actions workflow files.

    Other notes:

    • Improper authentication to the GitHub API manifests as a 404 error in order to prevent bad actors from confirming the existence of private repos.
    • Fine-grained tokens give a better error message in this situation.

    I resolved this by adding the "workflow" permission to the bot's PAT. There shouldn't be any other errors due to permissions errors editing workflow files, but it's possible that other permissions issues could show up as a 404 error in the future - in that case, open a separate issue instead of re-opening this one.

  6. moved this from Sprint to Done in .NET Dockeron Aug 29, 2024
  7. mthalman commented on Aug 29, 2024

    @mthalman
    MemberAuthor

    This error was inconsistent because not every PR submitted by the bot edits the actions workflow files.

    FilePusher is only pushing files from the eng/common directory which doesn't have GH workflow files in it. So I'm confused how workflow permissions are involved here.

  8. lbussell commented on Aug 29, 2024

    @lbussell
    Member

    FilePusher is only pushing files from the eng/common directory which doesn't have GH workflow files in it. So I'm confused how workflow permissions are involved here.

    You are right. Then I wonder which of the following this scope applies to:

    • all .yaml/.yml files (seems most likely to me)
    • repos where GitHub Actions are enabled
    • repos which have a .workflows folder
  9. mthalman commented on Aug 29, 2024

    @mthalman
    MemberAuthor

    It must be a combination of them. We've been pushing YML files this whole time w/o issue up to this point. So that in itself isn't the issue. Things went bad when actions were enabled.

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

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions