Skip to content

Fix private leagues not populating in Trade for Items league selection - #10211

Draft
everix1992 wants to merge 5 commits into
PathOfBuildingCommunity:devfrom
everix1992:fix/trader-private-leagues
Draft

Fix private leagues not populating in Trade for Items league selection#10211
everix1992 wants to merge 5 commits into
PathOfBuildingCommunity:devfrom
everix1992:fix/trader-private-leagues

Conversation

@everix1992

Copy link
Copy Markdown

The trade site league endpoint only recognizes cookie sessions and silently ignores the OAuth bearer token, so private leagues never appeared after the OAuth port. Fetch them from the account API (which honors the token) and refresh the league list after login or a background token refresh.

Note: I'm not incredibly familiar with the codebase itself here and had claude assist me in finding and fixing the issue. Feel free to change as much of the code as is needed if what's changed here is inappropriate - I just wanted to be able to search for jewels in our private league

Fixes

  • Added a second route to pull leagues from the account specific endpoint and add private leagues to the league list when present. This route is not used when not authenticated.

Description of the problem being solved:

When logged in via OAuth, private leagues are not pulled into the list of available leagues to select/search when trading for items.

Steps taken to verify a working solution:

  • Logged out and verified that the leagues list is still populating correctly
  • Logged in via OAuth and verified that my private leagues were added to the leagues list and were searchable

Link to a build that showcases this PR:

No specific (or any) build is required. This applies to any account that is in a private league.

Before screenshot:

image

After screenshot:

image FYI Curse of the Gallbladder is my private league's name

everix1992 and others added 5 commits August 10, 2026 10:37
The trade site league endpoint only recognizes cookie sessions and
silently ignores the OAuth bearer token, so private leagues never
appeared after the OAuth port. Fetch them from the account API
(which honors the token) and refresh the league list after login
or a background token refresh.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Me8GVT6W3FLuZ8ugfYGwVv
- Build the account API auth header at send time instead of reusing
  one captured before the trade request, so a token refreshed mid-flight
  no longer 401s silently
- Fetch /account/leagues once per refresh (memoized per token, in-flight
  requests shared) instead of once per realm
- Guard both league-fetch callback paths against stale or duplicate
  writes when a login/refresh refetch supersedes an in-flight fetch
- Record the fetch token only on a clean fetch so failures retry, and
  surface private-league fetch failures as a notice
- Refetch league lists on logout so private leagues leave the dropdown
- Only run the auth-probe search when authenticated
- Don't send the bearer token to the trade-site league endpoint (it
  ignores it), and tolerate a missing realm field on account leagues

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Me8GVT6W3FLuZ8ugfYGwVv
- Extract TradeQuery:FetchLeaguesForRealm so the supersede guard, base-league
  sorting, notices, and retry bookkeeping exist in one place instead of two
  diverged copies; failed fetches now leave the realm unset so they retry,
  and the fetch token is only recorded once every realm has a clean list
- Restore the league dropdown selection by name, since a refetch can change
  the list order
- Route the account leagues request through PoEAPI:DownloadWithRateLimit,
  gaining token refresh, 401 retry, and rate limiting
- Refetch leagues from a single choke point via a new onAuthReset hook fired
  by PoEAPI:ResetDetails, covering logout, failed refreshes, and outdated
  scopes; the logout button now just calls ResetDetails
- Coalesce concurrent token refreshes in ValidateAuth: the refresh token is
  single-use, so two in-flight refreshes could invalidate the session

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Me8GVT6W3FLuZ8ugfYGwVv
- InsertRequest crashed on any policy missing from the pendingRequests
  init table, which broke the first authenticated account-leagues fetch;
  initialize the policy entry on demand and cover it with a spec
- Discard an in-flight token refresh whose refresh token no longer
  matches current state, so a logout or new login during the refresh
  is not overwritten by the stale result
- Track the token a league-fetch pass started with, closing the gap
  where a logout during an in-flight authenticated pass compared
  nil == nil and skipped the refetch, leaving private leagues visible
- Discard private-league results that complete after logout, and re-key
  the cache after a transparent token rotation so it still hits

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Me8GVT6W3FLuZ8ugfYGwVv
@everix1992
everix1992 marked this pull request as draft August 12, 2026 20:39
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