Skip to content

fix(budget): make the billing permission opt-in so it degrades instead of dying - #131

Merged
ExtraToast merged 1 commit into
mainfrom
fix/budget-optional-billing-permission
Aug 29, 2026
Merged

fix(budget): make the billing permission opt-in so it degrades instead of dying#131
ExtraToast merged 1 commit into
mainfrom
fix/budget-optional-billing-permission

Conversation

@ExtraToast

Copy link
Copy Markdown
Contributor

My previous fix made it worse

#130 requested permission-organization-plan: read unconditionally. The result:

##[error]The permissions requested are not granted to this installation.

create-github-app-token does not degrade when asked for a permission the installation does not hold — it fails the job. So the watchdog now stopped at token minting, before it could report anything at all. That is strictly worse than running and saying it cannot read billing.

Fix

The permission is behind a new app-has-billing-permission input, default false. Set it true only once the App has actually been granted "Organization plan" (read).

Token precedence is now most-capable-first:

App-with-billing  ->  BUDGET_TOKEN  ->  plain App token  ->  github.token

BUDGET_TOKEN deliberately outranks the plain App token, because that token is known not to be able to read billing.

What you need to do to make this actually work

One of:

  1. Grant the App "Organization plan" (read), accept the updated installation permissions, then set app-has-billing-permission: true on the caller. Best end state — no PAT to rotate.
  2. Add a BUDGET_TOKEN secret with org billing read access. Works immediately, no App changes.

Until one of those happens the watchdog will run, fail loud, and tell you exactly this — which is the correct behaviour, but it is not yet watching anything.

The reusable workflow's own arithmetic was verified against live billing data across all three threshold branches in #128; what is unresolved is purely access.

…d of dying

Requesting "Organization plan" unconditionally made things worse, not better.
create-github-app-token does not degrade when asked for a permission the
installation does not hold -- it fails the job. So the watchdog stopped at
token minting, before it could report anything, which is strictly worse than
running and saying it cannot read billing.

The permission is now behind app-has-billing-permission, default false. Set it
true only once the App has actually been granted the permission. Until then
supply BUDGET_TOKEN, which now takes precedence over an App token that is
known not to be able to read billing.

Token precedence is therefore: App-with-billing, then BUDGET_TOKEN, then
plain App token, then github.token -- most-capable first, so the watchdog uses
whatever access it actually has rather than the first thing it finds.

Refs #126
@ExtraToast
ExtraToast merged commit 12dd0fb into main Aug 29, 2026
6 checks passed
@ExtraToast
ExtraToast deleted the fix/budget-optional-billing-permission branch August 29, 2026 21:13
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.

1 participant