fix(provisioning): surface the server's error instead of a bare axios 401 - #1026
Draft
posthog[bot] wants to merge 1 commit into
Draft
fix(provisioning): surface the server's error instead of a bare axios 401#1026posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
… 401 The three provisioning calls never inspected the HTTP status or the response body, so any auth failure reached the user as "Request failed with status code 401" and reached error tracking via exception autocapture with no step, status, or region attached. Wrap them in a helper that turns HTTP and schema failures into a ProvisioningError carrying the step, status, region, and whether a base URL was pinned, and reads the server's message out of the response body. The signup flow now routes any 401/403 into the login-flow fallback rather than gating that recovery on an "already associated" substring match, and every failure is captured once with its provisioning context. Generated-By: PostHog Code Task-Id: 1e77c0da-fb62-4a68-ac7e-8f4663c38741
🧙 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
A wizard signup run died on an opaque
Request failed with status code 401.provisionNewAccountfired three bareaxios.postcalls (/account_requests,/oauth/token,/resources) and never inspected the HTTP status or the response body, so the rawAxiosErrorbubbled up toaskForProvisioningSignup— which only knew how to recover from one specific substring (already associated) and aborted the run. The captured exception had nostepproperty, meaning it was picked up by exception autocapture rather than a taggedcaptureException: no status, no server message, no region or base-URL context. This sits on the signup critical path, so if real users hit it we currently cannot tell why.Changes
ProvisioningErrorinsrc/utils/provisioning.tscarrying the failing step, HTTP status, region, and whether a--base-urlwas pinned; aprovisioningPosthelper wraps all three calls and turns HTTP and schema failures into it, reading the server's message out of the response body (the API's{error: {message}}, DRF's{detail}, and the OAuth endpoint's RFC 6749{error, error_description}).wizard provision, CI install) records the provisioning context instead of relying on autocapture. An existing-account result stays uncaptured — it's an expected outcome the caller recovers from.askForProvisioningSignupnow routes any 401/403 into the browser login fallback instead of gating that recovery on a substring match.Test plan
Seven new cases in
src/utils/__tests__/provisioning.test.tscover the status + server message surfacing per step, the pinned-instance hint, the analytics properties, network failures, existing accounts, and malformed responses. Full suite green:pnpm build && pnpm test && pnpm fix(1668 tests).Created with PostHog Desktop from this inbox report.