Skip to content

Add an owner repair for guild sync roles replaced on Oct 17 - #209

Merged
Maselkov merged 1 commit into
masterfrom
guildsync-repair
Oct 25, 2026
Merged

Maselkov merged 1 commit into
masterfrom
guildsync-repair

Conversation

@Maselkov

Copy link
Copy Markdown
Owner

Summary

On Oct 17, between 15:50 and 18:20 UTC, during the first hours after the switch to a standalone bot, guild sync replaced every rank role in 234 servers (1,512 ranks) with new roles of the same names. The old roles are still on those servers, and on their members, but nothing syncs them any more. A server admin reported it.

This adds >guildsync_repair, an owner-only text command that puts them back:

  • Input: a JSON file attached to the command, listing each affected sync with each rank's old and replacement role ids. It was built from the production dumps from before and after Oct 17, and isn't committed.

  • What it changes: for each rank, it relinks the old role and deletes the replacement. It only does so if all of these hold:

    • the rank still points at the replacement, so nothing has changed it since;
    • the old role still exists, checked with Discord rather than the bot's cache;
    • the old role is below the bot's top role.

    Anything else is left as it is, with the reason in the report.

  • Dry run by default: >guildsync_repair apply makes the changes. Either way it replies with counts of each outcome and attaches a per-server report.

  • Members: they keep the old roles they still have. The next sync pass adds or removes rank roles as usual.

Locking: a server's guild syncs now run one at a time behind a per-server lock, and the repair takes the same lock. Without it, a sync that had already read the replacement ids could recreate a role the repair just deleted. It also stops a member-join sync and the minute loop from creating the same roles twice.

Cause: not found yet.

  • For the 104 affected syncs that also have a guild tag role, the bot found the tag role in the same pass. So the role cache was fine, but the rank role ids it used didn't match what's stored.
  • The guild sync code was the same before and after the switch, and nothing has been recreated since 18:20 that day.
  • Bot logs from that window would help.

Test plan

  • tests/test_guildsync_repair.py:
    • a dry run changes nothing;
    • applying relinks and deletes the replacements;
    • each reason a rank is kept;
    • servers the bot left, removed syncs, and missing permissions;
    • a sync waits while its server's lock is held (fails without the lock);
    • the owner command's dry run, apply and missing attachment.
  • Full suite with MongoDB: 753 passed, command tree unchanged. ruff check clean.
  • On prod: dry run first, check the report, then apply.

🤖 Generated with Claude Code

On 2026-10-17, in the first hours after the switch to a standalone bot,
guild sync replaced every rank role in 234 servers with new roles of the
same names. The old roles are still there, but no longer synced.

>guildsync_repair takes a JSON file of each affected sync's old and
replacement role ids (built from the database dumps either side of it).
For each rank it relinks the old role and deletes the replacement, but
only if the rank still points at the replacement, the old role still
exists (checked with Discord, not the cache) and is below the bot's top
role. It's a dry run unless given `apply`, and replies with the counts
and a per-server report.

A server's syncs now run one at a time behind a per-server lock, which
the repair also takes, so a sync can't recreate a role mid-repair.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Maselkov
Maselkov merged commit 7b5b5c5 into master Oct 25, 2026
6 checks passed
@Maselkov
Maselkov deleted the guildsync-repair branch October 25, 2026 10:27
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