fix: save avatars from own GoToSocial and Bluesky PDSes (v2.13.1)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
PhilandClaude Opus 5.5 committed 2026-11-10 12:56:04 -07:00
1 parent f3ed1b3488
commit 65fc246d55
7 files changed
+145 -11

No files matched your search

@@ -0,0 +1,33 @@
# v2.13.1: Avatar fetching in production
## Problem
After deploying v2.13.0, backfeed stored responses but no avatar was saved:
- GoToSocial avatars (`https://social.../fileserver/...`):
`SSRFBlockedError: Blocked request to private IP: 172.20.0.5`. Inside the
container the GoToSocial host resolves to the reverse proxy's internal
address (the deployment's hairpin `extra_hosts` entry).
- Bluesky avatars (`https://cdn.bsky.app/img/avatar/...`): HTTP 403 from
BunnyCDN. From the server, the CDN answers 403 over IPv4 and 200 over
IPv6; the container has no IPv6 route. From elsewhere IPv4 works.
## Fix (`starpunk/avatars.py`, `_download`)
- The host of `GOTOSOCIAL_URL` is fetched with a plain HTTP client (no
redirects, 1 MB limit), as `MastodonClient` already talks to it. Every
other host still goes through `safe_get`, so private addresses stay
blocked.
- `cdn.bsky.app/img/<kind>/plain/<did>/<cid>` URLs are fetched from the
account's PDS with `com.atproto.sync.getBlob`; the PDS comes from the DID
document (`plc.directory` for `did:plc`, `/.well-known/did.json` for
`did:web`). Both requests use `safe_get`. The cache file is still named
after the original URL.
## Verification
- `tests/test_backfeed.py::test_avatars_from_own_gotosocial_and_bluesky_pds`:
own GoToSocial on a private address is fetched, a Bluesky CDN URL is
fetched from its PDS, another private address is still refused.
- Checked against the real PLC directory and a bsky.network PDS.
- From the production server: getBlob over IPv4 returns the image (200).