Skip to content

Make backlog_metrics.py's User Billing Read Opt-In, Since a Fine-Grained Token Cannot Reach It #4370

Done

Description

@ptr727

scripts/backlog_metrics.py reads the owner's billing through fetch_billing, which calls GET /users/{username}/settings/billing/usage. Where the owner is a user account and the token is a fine-grained personal access token, that read cannot succeed.

Evidence (measured 2026-11-23)

  • The call returns HTTP 403 Resource not accessible by personal access token with the header X-Accepted-Github-Permissions: plan=read. /usage/summary answers the same.
  • GitHub's billing usage docs list "Plan" user permissions (read) for all four user endpoints. The org endpoints take "Administration" organization permissions (read).
  • The fine-grained token settings page offers no "Plan" permission to grant. Granting Administration (Read-only) left the read at 403, which matches the docs, since Administration covers org billing only.
  • So a user account's billing needs a classic token. The fleet's metrics consumer holds only a fine-grained read-only token, by design.

Effect

The script still exits 0 and records the failure in billing.error, plus a Billing was unavailable for <month>: ... line in notes. A consumer then reports billing unavailable every week. HomeAutomation-Config's weekly fleet report now drops billing and those notes as it reads the JSON, so it no longer depends on this. It works with either fix below.

Suggested fix

Make the billing read opt-in, for example --billing, defaulting off. Or skip it for a User owner. Where it is skipped, emit billing: null and no billing note, so a skipped read is not reported as a failed one. The Markdown output's billing line follows the same rule.

Activity

  1. added
    script
    on Nov 23, 2026
  2. ptr727 commented on Nov 24, 2026

    @ptr727
    OwnerAuthor

    Released (2026-11-24): PR #4392 merged to develop at 054e8fd; branch and worktree cleaned up, so this claim holds no files. The issue closes on promotion.

    Backlog burndown claim (away run 2026-11-24, round 1, group 3): branch burndown/backlog-metrics-attention, issues #4284, #1095 (its duplicate), #4299, #4370.

    Predicted files:

    • scripts/backlog_metrics.py.
    • tests/test_backlog_metrics.py.
    • scripts/README.md, the backlog_metrics.py JSON field list.

    Any other group needing one of these files waits for this branch to merge.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    script

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions