FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

🔧 Add a GitHub App manifest with the needed privileges by LuShadowX · Pull Request #59 · sanitizers/patchback-github-app · GitHub

🔧 Add a GitHub App manifest with the needed privileges - #59

Merged
webknjaz merged 4 commits into
sanitizers:masterfrom
LuShadowX:app-manifest
Jul 31, 2026
Merged

🔧 Add a GitHub App manifest with the needed privileges#59
webknjaz merged 4 commits into
sanitizers:masterfrom
LuShadowX:app-manifest

Conversation

Copy link
Copy Markdown
Contributor

The permission manifest you asked for in #57 (comment), as its own PR.

Everything in it is derived from the code rather than from the settings page, and it lines up with the list you posted in #10:

  • pull_request is the only event with handlers (closed and labeled in event_handlers.py);
  • contents: write — the clone and the git push of the backport branch, plus reading .github/patchback.yml;
  • pull_requests: write — creating the backport PR, and the comment/lock calls on the original one;
  • checks: write — the Backport to <branch> check run.

Two things I left as comments instead of values: the webhook URL, which is per-deployment, and Single file, since a manifest can't say which file and contents already covers it. name is commented out too because App names are globally unique.

Refs: #10

Comment thread app.yml Outdated
checks: write

# The deployed App additionally has `Single file` (`.github/patchback.yml`)
# read access, but a manifest cannot declare which file that would be, and

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why? It should be okay to hardcode this for now.

Comment thread app.yml Outdated
# backport label landing on an already merged PR, and a labeled PR being
# merged.
default_events:
- pull_request

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I prefer zero-indent sequences in my YAML:

Suggested change
- pull_request
- pull_request

If you'd like, here's an idea for another PR (or a few, for linters): https://github.com/tox-dev/tox-pre-commit/blob/32376c4/.pre-commit-config.yaml / https://github.com/tox-dev/tox-pre-commit/blob/32376c4/.yamllint

Comment thread app.yml Outdated

# GitHub App names are globally unique and `patchback` is taken by the public
# instance, so a private one has to pick its own name at registration time:
# name: patchback-myorg

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Technically, this app isn't currently set up to actively support multiple deployments, so I wouldn't care about having this hardcoded with the actual main app ID for now:

Suggested change
# name: patchback-myorg
name: patchback

This manifest isn't used by anything anyway. Eventually, I hope, octomachinery could implement the same manifest flow as Probot. Then, we could think of whether this need to change, but not now. Now, I just wanted to have something structured in one place and this pre-existing format seemed like a good fit.

Copy link
Copy Markdown
Contributor Author

Done — name: patchback, zero-indent sequence, and single_file: read is now declared instead of explained away (which file it is still comes from the App's settings, so I kept a line about that). Also dropped the private-instance framing in the header, since it no longer matches a hardcoded name.

On your linter note: the repo is on pre-commit.ci but has no config, which is what the red error during ci config on every PR is. Opened #60 with a small green first pass using your .yamllint. That also turned up this manifest needing --- and a shorter Refs line to survive yamllint --strict, so I fixed that here too — this PR will go green once #60 lands.

Comment thread app.yml
checks: write

# Reading `.github/patchback.yml`. Which file that is gets configured in
# the App's settings, not in the manifest.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@LuShadowX does the manifest not have a place for listing the actual file paths? I think that modern GH App creation UI even allows listing several files IIRC.

Copy link
Copy Markdown
Contributor Author

You're right about the UI — it does take several paths now, and the API reflects that: an installation object carries single_file_paths alongside single_file_name, plus a has_multiple_single_files flag.

The manifest is the gap. The documented parameter set is only these twelve keys — name, url, hook_attributes, redirect_url, callback_urls, setup_url, description, public, default_events, default_permissions, request_oauth_on_install, setup_on_update — and there's nothing among them for single-file paths:
https://github.com/github/docs/blob/main/content/apps/sharing-github-apps/registering-a-github-app-from-a-manifest.md#L57-L72

So single_file: read is all the manifest can express; which file it applies to stays a settings-page field. Those single_file_paths are read-only and only exist once an installation does, so there's nothing to hardcode here even if we wanted to. Happy to drop the comment to a single line, or cut it entirely, if you'd rather the file didn't explain itself.

One gap while I'm in here: event_handlers.py names Workflows: write next to Contents: write in the push failure it raises, and the manifest doesn't declare workflows at all. I left it out because a backport only needs it when the patch touches .github/workflows/, so it isn't unconditionally required — but the deployed App presumably has it, and the point of this file is to be the one place the privileges are written down. Want me to add it?

Lists the events and repository permissions Patchback needs, so a
private instance can be registered from the manifest instead of the
privileges being reconstructed from the code.
Address review: the App does not support multiple deployments, so the
name is set to `patchback` instead of being left commented out, and the
private-instance framing is dropped. Sequences are unindented, and the
`single_file` permission is declared rather than explained away.
Add the explicit document start/end markers the other YAML in this repo
uses, and drop the `* ` bullets from the Refs comment so the two long
URLs count as non-breakable words.

Copy link
Copy Markdown
Member

You're right about the UI — it does take several paths now, and the API reflects that: an installation object carries single_file_paths alongside single_file_name, plus a has_multiple_single_files flag.

The manifest is the gap. The documented parameter set is only these twelve keys — name, url, hook_attributes, redirect_url, callback_urls, setup_url, description, public, default_events, default_permissions, request_oauth_on_install, setup_on_update — and there's nothing among them for single-file paths: github/docs@main/content/apps/sharing-github-apps/registering-a-github-app-from-a-manifest.md#L57-L72

So single_file: read is all the manifest can express; which file it applies to stays a settings-page field. Those single_file_paths are read-only and only exist once an installation does, so there's nothing to hardcode here even if we wanted to. Happy to drop the comment to a single line, or cut it entirely, if you'd rather the file didn't explain itself.

Thanks for digging into this! I'm okay with having a comment if there's nothing else to be done.

One gap while I'm in here: event_handlers.py names Workflows: write next to Contents: write in the push failure it raises, and the manifest doesn't declare workflows at all. I left it out because a backport only needs it when the patch touches .github/workflows/, so it isn't unconditionally required — but the deployed App presumably has it, and the point of this file is to be the one place the privileges are written down. Want me to add it?

I've checked the actual app entity, and it does have this privilege requested. I vaguely recall getting a Sentry alert related to it when GH introduced privilege separation for the workflows folder and adding it. Here's the screenshot:

So I think the manifest should also have this privilege requested with an explanatory comment. It's pretty common to backport CI/infra/GHA stuff, I'd even say that it's important to keep it in sync across a set of supported/stable branches for an extended period of time so that any backports that happen to touch those files apply w/o conflicts, especially if they are security fixes or things involved in the process of cutting releases from the LTS branches.

The deployed App has it, and pushing a commit that touches
`.github/workflows/` needs it in addition to `Contents: write`.

Copy link
Copy Markdown
Contributor Author

Added in acc4fb3 — workflows: write, sitting with the other write privileges, with a comment saying why: contents: write on its own cannot push a commit touching .github/workflows/, so a backport of any CI change dies at the push stage, which is exactly the error event_handlers.py:222 names both privileges in. The sync argument is in the comment too, since that is the part someone reading the manifest would not guess.

Screenshot matches the file now, except single_file, which stays a comment as discussed.

yamllint --strict clean.

Comment thread app.yml
# including unlocking and re-locking it when it was locked.
pull_requests: write

# Publishing the `Backport to <target branch>` check run that mirrors the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Also creating a check suite (which is an implementation detail I suppose so probably doesn't really matter if it's mentioned here explicitly).

webknjaz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Alright, I think this is ready to go in. Thanks!

webknjaz merged commit 8360fbd into sanitizers:master Jul 31, 2026
1 check passed

Copy link
Copy Markdown
Member

yamllint --strict clean.

I know that agentic tools are eager to game the system and run the underlying tooling directly but only do this if you really know what you're doing. The contributors are always expected to use the project's main workflow tool configured. In many Python projects it's tox that is internally configured to run other things properly with correct configurations (like invoking pytest/pre-commit/etc), in some it'd be nox/uv/make or something like that. In some, you'll see several layers, and you can go for something in the middle (pre-commit/prek). But in general, unless you're running something the contrib file says you to run or the CI is configured to run, it wouldn't be considered supported and you may end up in a situation that in behaves in a way that is unexpected and wouldn't even know it.

Copy link
Copy Markdown
Contributor Author

Thanks for the merge, and for spelling out the tooling expectation — that's a fair hit. Now that the pre-commit config is in, I'll report what pre-commit run gives rather than invoking the individual linters with my own flags, since that's the configuration the CI actually enforces.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

2 participants


Back | FazBrowse Home | New Git URL