Bodyless Bluesky token refresh; one platform's failure no longer 500s post metrics - #316
Open
gynsus wants to merge 1 commit into
Open
Bodyless Bluesky token refresh; one platform's failure no longer 500s post metrics#316gynsus wants to merge 1 commit into
gynsus wants to merge 1 commit into
Conversation
…efresh
Two halves of the same outage. bsky.social started rejecting
refreshSession calls that carry a body — a data-less post() still sends
an empty JSON body — so the scheduled refresh failed every cycle and the
account limped along on the credential re-auth fallback, leaving windows
with a dead access token. During those windows the analytics service
threw out of PostMetricsFetcher's match and a single provider's exception
turned the whole get-post-metrics aggregate into a 500 for every post.
The refresh now uses send('POST') with no body, and forPlatform wraps
each provider in a try/catch that logs which platform failed and returns
an unsupported/error entry so the other platforms still report.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two fixes from one production incident: the
get-post-metricsMCP tool (and the web post-analytics panel behind the samePostMetricsFetcher) returned HTTP 500 for a multi-platform post.Fix 1: bsky.social rejects the refresh call TryPost sends
Laravel's
Http::post($url)with no data still sends an empty JSON body ({}withContent-Type: application/json). bsky.social now rejectscom.atproto.server.refreshSessioncalled that way:so every Bluesky token refresh failed, the account flapped, and refresh kept being retried. The call now goes through
send('POST', …), which sends no body at all.BlueskyRefreshSessionTestpins the contract ($request->body() === '') so a helper refactor can't quietly reintroduce the body.Fix 2: one platform's exception nuked the whole metrics aggregate
PostMetricsFetcher::forPlatform()let provider exceptions propagate, so a single misbehaving platform (here: Bluesky mid-token-flap) turned "metrics for this post" into a 500 for every platform of the post — the MCP tool, the REST endpoint, and the web panel all share this path. Per-platform fetches are now wrapped: a failure logs a warning and degrades that one platform to['unsupported' => true, 'reason' => 'error'], the shape the frontend already renders as "metrics unavailable".Testing
New
BlueskyRefreshSessionTestand aPostMetricsFetcherTestcase for the degrade path;ConnectionVerifierTestpasses. Verified live: the failing post's metrics now render for all healthy platforms, and Bluesky refresh succeeds against bsky.social.