Skip to content

Fix(forks): Check rename rights before renaming #217

Closed

Description

Problem

#204 moves fork creation and renaming out of the App into the Prepare forks job, under a machine account's classic token (fork_pool_token). When a target repository has been renamed, fork_pool.start() finds its fork under the old name and renames it with PATCH /repos/{fork}. GitHub allows that to an account with admin on the repository alone.

The rollout in #204 asks for an account that belongs to the fork organisations "with permission to create repositories there". That makes the account admin of the forks it creates, but not of the forks already in the pools, which the App created. Renaming one of those fails with a 403, and that target's publish then fails as a missing fork, with a reason that points at the forks job but not at the account's rights.

Required behaviour

  1. Before the PATCH, start() reads the found fork (GET /repos/{found}; the reply carries the token's permissions). When permissions.admin is not true, it fails that target with "<pool account> cannot rename <found>: it needs admin on the fork, or owner of <fork_org>", and makes no write. The other targets go ahead, as for any failure there.
  2. A fork the job has just created is the account's own, so the check passes; a test proves the created-then-renamed path still works.
  3. docs/DESIGN.md §10.6 (added by Feat(publish): Prepare forks in a separate job #204) and the README's rollout say the account needs admin on every repository in the fork organisations (owner, or a base permission of admin), and why: renames.

Acceptance criteria

  • Tests in tests/test_fork_pool.py: a listed fork the token lacks admin on fails with the reason and no PATCH; with admin it is renamed as today; a fork created in the same run is renamed; a target whose fork is already present makes no permission read.
  • uv run python -B -m unittest discover -s tests passes.
  • prek run --files <changed files> and the aislop gate report no findings.

Depends on

#204, which adds scripts/fork_pool.py.

Out of scope

  • Whether the App's installation covers the forks the account creates (its own issue).
  • The token's scopes, which check_token already holds to public_repo.

Activity

  1. lf-releng-code-monkey-bot commented on Nov 22, 2026

    @lf-releng-code-monkey-bot
    Contributor

    🐒 An AI agent has proposed a change for this issue: pull request #222 (head c09e6db). The Copilot review of it is clean. Still pending after 8 minutes and not waited for, so its result is unknown: pre-commit.ci - pr. An antagonistic review was requested from the review bot.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions