snarfed / bridgy-fed

🌉 A bridge between decentralized social network protocols
https://fed.brid.gy
Creative Commons Zero v1.0 Universal
554 stars 29 forks source link

AP => AT: Unfollow didn't register on bridged account #1338

Open TomCasavant opened 22 hours ago

TomCasavant commented 22 hours ago

Here's an interesting one, I accidentally followed a bluesky user and immediately unfollowed them (https://bsky.app/profile/okpierre.bsky.social). So I'm not following the account from my @tom@tomkahe.com account. Bridgy must have seen that unfollow because it doesn't show up in the web-ui https://fed.brid.gy/ap/@tom@tomkahe.com/following.

But if you view the bridged profile from bluesky it still shows me following that user, https://bsky.app/profile/tom.tomkahe.com.ap.brid.gy/follows

snarfed commented 17 hours ago

Hey, thanks for filing! I see it, will try to fix.

snarfed commented 17 hours ago

Background:

Follow https://tomkahe.com/74cbd52c-4b35-4d2b-b12c-3bc6382a8af7 created 2024-9-18 22:44:47 UTC updated 2024-9-18 22:44:50 UTC

{
  "id": "https://tomkahe.com/74cbd52c-4b35-4d2b-b12c-3bc6382a8af7",
  "type": "Follow",
  "actor": "https://tomkahe.com/users/tom",
  "object": "https://bsky.brid.gy/ap/did:plc:gdtnb37zy4lfw4skkjp44fvv",
  "url": "https://tomkahe.com/users/tom#followed-did:plc:gdtnb37zy4lfw4skkjp44fvv"
}

Undo of Follow https://tomkahe.com/users/tom#follows/4578/undo created 2024-9-18 22:44:48 UTC updated 2024-9-18 22:44:49 UTC

{
  "id": "https://tomkahe.com/users/tom#follows/4578/undo",
  "type": "Undo",
  "actor": "https://tomkahe.com/users/tom",
  "object": {
    "id": "https://tomkahe.com/74cbd52c-4b35-4d2b-b12c-3bc6382a8af7",
    "type": "Follow",
    "actor": "https://tomkahe.com/users/tom",
    "object": "https://bsky.brid.gy/ap/did:plc:gdtnb37zy4lfw4skkjp44fvv"
  }
}
snarfed commented 17 hours ago

This was a race condition. The Undo started processing before we finished processing and sending the Follow to ATProto. Specifically, the ATProto copy of the follow (at://did:plc:glvkfxk3igeeybszoue3apxi/app.bsky.graph.follow/3l4hmaua3fyd2) wasn't yet added to the follow's Object.copies, so we failed the Undo because we thought we hadn't created an ATProto copy.

Not sure exactly what to do here. I guess I could make this kind of missing copy error retryable.

snarfed commented 17 hours ago

This is where we'd do that:

https://github.com/snarfed/bridgy-fed/blob/5330dca6e2181dbd0e9b5567c06d7409914c2708/atproto.py#L593-L597