Skip to content

Follow GitHub repository and organization renames - #278

Open
ndbroadbent wants to merge 4 commits into
mainfrom
github-renames
Open

ndbroadbent wants to merge 4 commits into
mainfrom
github-renames

Conversation

@ndbroadbent

@ndbroadbent ndbroadbent commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

Why

On 5 Dec 2026 the GitHub organization visualci-com was renamed to visualcihq. GitHub answers a renamed repository's old /repos/{owner}/{name}/... path with a 301, and VisualCI's outbound client follows no redirects, so every check run and PR comment for a project with a stale repository_url failed. A coordinator fixed projects.repository_url by hand in production; this makes VisualCI handle it on its own.

What changes

  1. Calls by GitHub's permanent repository ID. github_app::repo_api / Repository::github_api_path give /repositories/{id} when the numeric ID is known, and /repos/{owner}/{name} only when it isn't. Moved to it:

    • check runs and PR comments (forge/report.rs);
    • branch checks in sync::close_deleted_branches (one call fewer: no separate lookup of the path by ID);
    • collaborator listing in webhooks::reach;
    • the visibility/licence check in open_source (one GET /repositories/{id} instead of looking up the path by ID and then GET /repos/{path}).

    Still path-based, on purpose: linking a repository by the URL someone typed (installation_for, permission, repository_id). The ID isn't known yet at that point, and the name is current.

  2. The hourly sync follows renames. reach already reads each linked repository's full_name by ID. It now records that name (Reach::paths), and sync::follow_renames sets projects.repository_url to https://github.com/<full_name> where it differs. It also updates the repository picker's user_repositories.full_name cache, so the picker doesn't try to link by a stale name. Both are one bulk query each. Synced gains a renamed count.

  3. installation_target / renamed. installations::from_webhook sets github_installations.account_login to the new login. webhooks::handle (ForgeEvent::AccountRenamed) rewrites the repository_url of github projects on that installation whose owner segment is the old login (case-insensitive), and the installation's user_repositories.full_name. Both logins are checked as GitHub logins before use.

  4. The repository renamed/transferred handling (ForgeEvent::Moved) is unchanged; links still match by ID.

docs/design.md describes this under "Keeping in step", and there's a changelog line under 2026-12-05.

Tests

  • forge_reports::a_renamed_repository_still_gets_its_check_and_comment: the stored URL is stale, /repos/* answers 301, stray requests are refused, and the check and comment still go to /repositories/42/....
  • forge_reports::a_link_without_its_repository_id_posts_by_name: a link with no ID falls back to /repos/acme/web/....
  • forge_sync::a_renamed_repository_is_followed_within_the_hour: an organization rename and a repository rename are both followed, the picker cache is updated, and a second run changes nothing.
  • webhooks::a_renamed_account_moves_its_installations_projects: an installation_target delivery updates the login, matches the old owner case-insensitively, and leaves another account's and another installation's projects alone.
  • Existing fakes now use /repositories/{id}.

The full cargo test --test app passed (421 tests), and cargo clippy --all-targets is clean.

Outside the repo

The App's webhook event subscriptions are set in the GitHub App's settings, not in this repo. GitHub's docs say installation is sent to every App automatically; they don't say whether installation_target is too. Check the App's settings or its delivery log after the next account rename. If the event isn't delivered, the hourly sync still follows the rename within an hour.


Get evidence
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@visualci-com

visualci-com Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

VisualCI

docspring/visualci · build #1452 · 4 changed, 574 unchanged · waiting for review

This PR vs base: 54 changed, 17 added since #1157, across 8 builds · 4 not approved yet

Snapshot What changed Close-up: before → after
screenshots/changelog/1440-dark (changed)
before · after

Content below here moved
screenshots/changelog/1440-light (changed)
before · after

Content below here moved
screenshots/changelog/390-dark (changed)
before · after

Content below here moved
screenshots/changelog/390-light (changed)
before · after

Content below here moved

docspring/visualci · journeys · build #1450 · 53 unchanged · no changes

This PR vs base: 53 added, 50 removed since #1151, across 10 builds

Updated as builds change. Agents can review with VisualCI's MCP tools.

ndbroadbent added a commit that referenced this pull request Dec 5, 2026
…count renames change nothing

Review fixes for #278:

- reach: a repository whose collaborators answer 403 or 404 (a public repo
  transferred to an account the installation doesn't cover) is unseen, so its
  links are unlinked, instead of failing the hourly sync for everyone. A 403
  with no calls left is still the rate limit's error. Its path is recorded for
  follow_renames only after collaborators succeeded, keyed by installation, so
  a project is only ever pointed at an owner its installation covers.
- follow_renames is one statement (the picker cache in a data-modifying CTE),
  with a comment on the fixed github.com host.
- installation_target renamed: GitHub is asked what the account is called now
  and only a rename to that name is applied (a late acme->beta after beta->acme
  can't be told apart by logins). The installation's login changes only from
  `from`; URLs move only when it did, when it already reads `to`, or when no
  installation row exists. The unguarded store in installations::from_webhook
  is gone, and an installation whose account login isn't a valid login isn't
  recorded.
- repo_api's doc says which client refuses redirects.

Tests: an unreadable repo doesn't stop the sync (others followed, it isn't
renamed, it's unlinked), a GitLab project with the same ID and a 404 repo keep
their URLs; stale and rejected-login renames change nothing; the existing
check run is PATCHed and the comment edited by ID after a rename; linking's
visibility/licence check is proven to use /repositories/42.
ndbroadbent added a commit that referenced this pull request Dec 5, 2026
…Hub's current login

Review fixes for #278 (246d357):

- collaborators returns None (unseen, so unlinked) only for a 404 or a 403
  "Resource not accessible by integration" without retry-after. A rate limit's
  answer (429, or a 403 with no calls left, retry-after or a rate-limit
  message) is an error rate_limited() recognises, from get(), collaborators
  and installation_token alike, so the hourly sync defers with a healthy
  heartbeat. Any other 403 fails the run and unlinks nobody.
- account_renamed: once GitHub confirms the delivery's new login, the
  installation's login is set to GitHub's whatever VisualCI had, and URLs and
  picker names move from both the delivery's `from` and the stored login, so
  acme->beta->gamma delivered after GitHub says gamma, or a lost delivery,
  ends at gamma.
- follow_renames is compare-and-set: reach snapshots each link's URL before
  asking GitHub, and a URL a webhook changed meanwhile isn't overwritten.
- A repository renamed/transferred delivery moves only links through the
  installation that sent it (a delivery without an installation is ignored).

Tests: secondary-limit, primary-limit and 429 answers defer and leave the
project linked; a bare 403 errors without unlinking; acme->beta->gamma and a
lost delivery end at gamma; the sync doesn't undo a webhook's newer URL; a
rename leaves another installation's link to the same repository alone.
ndbroadbent added a commit that referenced this pull request Dec 5, 2026
…count renames change nothing

Review fixes for #278:

- reach: a repository whose collaborators answer 403 or 404 (a public repo
  transferred to an account the installation doesn't cover) is unseen, so its
  links are unlinked, instead of failing the hourly sync for everyone. A 403
  with no calls left is still the rate limit's error. Its path is recorded for
  follow_renames only after collaborators succeeded, keyed by installation, so
  a project is only ever pointed at an owner its installation covers.
- follow_renames is one statement (the picker cache in a data-modifying CTE),
  with a comment on the fixed github.com host.
- installation_target renamed: GitHub is asked what the account is called now
  and only a rename to that name is applied (a late acme->beta after beta->acme
  can't be told apart by logins). The installation's login changes only from
  `from`; URLs move only when it did, when it already reads `to`, or when no
  installation row exists. The unguarded store in installations::from_webhook
  is gone, and an installation whose account login isn't a valid login isn't
  recorded.
- repo_api's doc says which client refuses redirects.

Tests: an unreadable repo doesn't stop the sync (others followed, it isn't
renamed, it's unlinked), a GitLab project with the same ID and a 404 repo keep
their URLs; stale and rejected-login renames change nothing; the existing
check run is PATCHed and the comment edited by ID after a rename; linking's
visibility/licence check is proven to use /repositories/42.
ndbroadbent added a commit that referenced this pull request Dec 5, 2026
…Hub's current login

Review fixes for #278 (246d357):

- collaborators returns None (unseen, so unlinked) only for a 404 or a 403
  "Resource not accessible by integration" without retry-after. A rate limit's
  answer (429, or a 403 with no calls left, retry-after or a rate-limit
  message) is an error rate_limited() recognises, from get(), collaborators
  and installation_token alike, so the hourly sync defers with a healthy
  heartbeat. Any other 403 fails the run and unlinks nobody.
- account_renamed: once GitHub confirms the delivery's new login, the
  installation's login is set to GitHub's whatever VisualCI had, and URLs and
  picker names move from both the delivery's `from` and the stored login, so
  acme->beta->gamma delivered after GitHub says gamma, or a lost delivery,
  ends at gamma.
- follow_renames is compare-and-set: reach snapshots each link's URL before
  asking GitHub, and a URL a webhook changed meanwhile isn't overwritten.
- A repository renamed/transferred delivery moves only links through the
  installation that sent it (a delivery without an installation is ignored).

Tests: secondary-limit, primary-limit and 429 answers defer and leave the
project linked; a bare 403 errors without unlinking; acme->beta->gamma and a
lost delivery end at gamma; the sync doesn't undo a webhook's newer URL; a
rename leaves another installation's link to the same repository alone.
ndbroadbent added a commit that referenced this pull request Dec 5, 2026
…count renames change nothing

Review fixes for #278:

- reach: a repository whose collaborators answer 403 or 404 (a public repo
  transferred to an account the installation doesn't cover) is unseen, so its
  links are unlinked, instead of failing the hourly sync for everyone. A 403
  with no calls left is still the rate limit's error. Its path is recorded for
  follow_renames only after collaborators succeeded, keyed by installation, so
  a project is only ever pointed at an owner its installation covers.
- follow_renames is one statement (the picker cache in a data-modifying CTE),
  with a comment on the fixed github.com host.
- installation_target renamed: GitHub is asked what the account is called now
  and only a rename to that name is applied (a late acme->beta after beta->acme
  can't be told apart by logins). The installation's login changes only from
  `from`; URLs move only when it did, when it already reads `to`, or when no
  installation row exists. The unguarded store in installations::from_webhook
  is gone, and an installation whose account login isn't a valid login isn't
  recorded.
- repo_api's doc says which client refuses redirects.

Tests: an unreadable repo doesn't stop the sync (others followed, it isn't
renamed, it's unlinked), a GitLab project with the same ID and a 404 repo keep
their URLs; stale and rejected-login renames change nothing; the existing
check run is PATCHed and the comment edited by ID after a rename; linking's
visibility/licence check is proven to use /repositories/42.
ndbroadbent added a commit that referenced this pull request Dec 5, 2026
…Hub's current login

Review fixes for #278 (246d357):

- collaborators returns None (unseen, so unlinked) only for a 404 or a 403
  "Resource not accessible by integration" without retry-after. A rate limit's
  answer (429, or a 403 with no calls left, retry-after or a rate-limit
  message) is an error rate_limited() recognises, from get(), collaborators
  and installation_token alike, so the hourly sync defers with a healthy
  heartbeat. Any other 403 fails the run and unlinks nobody.
- account_renamed: once GitHub confirms the delivery's new login, the
  installation's login is set to GitHub's whatever VisualCI had, and URLs and
  picker names move from both the delivery's `from` and the stored login, so
  acme->beta->gamma delivered after GitHub says gamma, or a lost delivery,
  ends at gamma.
- follow_renames is compare-and-set: reach snapshots each link's URL before
  asking GitHub, and a URL a webhook changed meanwhile isn't overwritten.
- A repository renamed/transferred delivery moves only links through the
  installation that sent it (a delivery without an installation is ignored).

Tests: secondary-limit, primary-limit and 429 answers defer and leave the
project linked; a bare 403 errors without unlinking; acme->beta->gamma and a
lost delivery end at gamma; the sync doesn't undo a webhook's newer URL; a
rename leaves another installation's link to the same repository alone.
@ndbroadbent
ndbroadbent force-pushed the github-renames branch 3 times, most recently from 195ece8 to 3d86791 Compare December 5, 2026 14:57
GitHub answers a renamed repository's old /repos/{owner}/{name} path with a
301, which VisualCI's client doesn't follow, so a rename (on 5 Dec 2026 the
visualci-com organization became visualcihq) broke checks and PR comments.

- Calls about a linked repository go to /repositories/{id}/... when GitHub's
  ID is known: check runs, PR comments, branch checks, collaborators and the
  visibility/licence check (now one call instead of two). /repos/{path} stays
  only for links without an ID and for linking by a typed URL.
- The hourly sync already reads each linked repository's name by ID; it now
  gives projects (and the picker's user_repositories cache) the current
  https://github.com/<full_name> where it differs.
- installation_target "renamed" updates github_installations.account_login and
  rewrites the installation's project URLs and cached repository names under
  the old login (case-insensitive) to the new one.

Tests: ID-based URLs (stale URL still posts by ID; no ID posts by name), the
sync following renames, an installation_target delivery; fakes moved to the
/repositories/{id} form.
…ry's ID path; the changelog line is an entry file

This branch has not been deployed

No deployments
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