fix(api): retry transient user/project fetch failures in CI auth path#928
Draft
posthog[bot] wants to merge 1 commit into
Draft
fix(api): retry transient user/project fetch failures in CI auth path#928posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
The CI / non-interactive auth path resolves the team/project id by calling fetchUserData first (inside fetchProjectDataWithApiKey). That call had no retry, so a brief upstream /api/users/@me/ 5xx or network blip propagated straight up through authenticate and killed the whole pre-run. Add retry-with-backoff for transient (5xx / network / timeout) failures in the idempotent GETs (fetchUserData, fetchProjectData) and a per-request timeout so a hung connection fails fast into that retry path. When retries are exhausted, handleApiError now surfaces a clearer, actionable terminal message distinguishing a temporary API outage from a connectivity problem, instead of the generic "Failed to fetch user data". 4xx (auth/scope/not-found) and parse errors are never retried. Generated-By: PostHog Code Task-Id: 4b8c0393-9452-408e-8646-ba240adcadd6
🧙 Wizard CIRun the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands: Test all apps:
Test all apps in a directory:
Test an individual app:
Show more apps
Results will be posted here when complete. |
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.
Problem
The wizard's CI / non-interactive auth path crashed when the first
/api/users/@me/call failed transiently. In CI mode without aprojectId,fetchProjectDataWithApiKeyhas to callfetchUserDatafirst to resolve the team/project id, and that call was not guarded by any retry or best-effort handling — so a brief upstream/api/users/@me/blip (5xx / network / timeout) propagated up throughauthenticateandscopeInstallDirToProjectand killed the whole CI pre-run.handleApiErrorhad no retry and fell back to a generic"Failed to fetch user data"for exactly the transient statuses worth riding out. Observed as a tight burst of failures across many users in a short window — the shape of a transient upstream hiccup, not a permanent bug.Changes
fetchUserDataandfetchProjectData. 4xx (auth / scope / not-found) and parse errors are never retried./api/users/@me/connection fails fast into the retry path instead of blocking the run indefinitely.handleApiErrornow surfaces a clearer, actionable terminal message distinguishing a temporary API outage from a connectivity problem, instead of the generic fallback.Since the first call genuinely needs the team id, it can't be swallowed like the second (best-effort)
fetchUserData— retry plus a better terminal message is the right shape.Test plan
src/lib/__tests__/api.test.tscovers: transient 5xx / network retries that recover, retry exhaustion surfacing the clearer messages, fast-fail on 4xx, and no-retry on parse errors.pnpm build && pnpm test(1453 tests) andpnpm fixall pass.Created with PostHog Code from this inbox report.