Skip to content

fix(provisioning): surface the server's error instead of a bare axios 401 - #1026

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/provisioning-error-context
Draft

fix(provisioning): surface the server's error instead of a bare axios 401#1026
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/provisioning-error-context

Conversation

@posthog

@posthog posthog Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Problem

A wizard signup run died on an opaque Request failed with status code 401. provisionNewAccount fired three bare axios.post calls (/account_requests, /oauth/token, /resources) and never inspected the HTTP status or the response body, so the raw AxiosError bubbled up to askForProvisioningSignup — which only knew how to recover from one specific substring (already associated) and aborted the run. The captured exception had no step property, meaning it was picked up by exception autocapture rather than a tagged captureException: 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

  • New ProvisioningError in src/utils/provisioning.ts carrying the failing step, HTTP status, region, and whether a --base-url was pinned; a provisioningPost helper 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}).
  • Failures are captured once, at the throw site, so every entry point (TUI signup, 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.
  • askForProvisioningSignup now routes any 401/403 into the browser login fallback instead of gating that recovery on a substring match.
  • When a pinned instance returns 401/403, the message points at the likely cause: that instance not having the wizard's OAuth client registered.

Test plan

Seven new cases in src/utils/__tests__/provisioning.test.ts cover 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.

… 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
@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

Run 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:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci basic-integration
  • /wizard-ci mcp-analytics
  • /wizard-ci revenue
  • /wizard-ci self-driving

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci revenue/stripe
  • /wizard-ci self-driving/astro
  • /wizard-ci self-driving/fastapi
  • /wizard-ci self-driving/nuxt
  • /wizard-ci self-driving/react-router
  • /wizard-ci self-driving/sveltekit

Results will be posted here when complete.

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.

0 participants