fix(ci): don't crash non-interactive run when early auth blips#940
Draft
posthog[bot] wants to merge 1 commit into
Draft
fix(ci): don't crash non-interactive run when early auth blips#940posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
The eager `authenticate()` call in `scopeInstallDirToProject` (added when it moved onto the ciPreRun critical path) was the only unguarded failure in a function whose contract is "every failure leaves the session untouched". A transient user/project lookup failure (network blip, 5xx) there surfaced as "Failed to fetch user data" and aborted the whole CI/non-interactive run. Wrap the early auth in try/catch: on failure, warn, fire an `auth-failed` agentic-detection outcome, and continue with the install dir as-is. The real auth is retried at bootstrap, so a persistent failure still aborts there — at the true critical point — while a transient blip no longer kills the run. Generated-By: PostHog Code Task-Id: 276512c1-4267-4c07-bb74-f169af2787e8
🧙 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
In CI / non-interactive mode with an API key but no
--project-id, the eagerauthenticate()call inscopeInstallDirToProjectroutes throughfetchProjectDataWithApiKey→fetchUserDatato derive the project id. That call was not guarded: any failure other than 401/403/404 (a network blip, timeout, or 5xx) surfaced as the literalApiError: Failed to fetch user dataand propagated up throughauthenticate→scopeInstallDirToProject→ciPreRun, killing the whole run.This is a recent regression: the early
authenticate()was moved onto theciPreRuncritical path, which made a transient user-lookup blip fatal. It also brokescopeInstallDirToProject's own documented contract — "every failure leaves the session untouched" — since the auth line was the one unguarded failure in the function. There's a telling asymmetry too: the parallel best-effort user fetch in the CI branch ofgetOrAskForProjectDatais already wrapped in try/catch and swallowed, but this path wasn't.Changes
Wrap the early
authenticate()inscopeInstallDirToProjectin try/catch. On failure it captures the exception, fires anauth-failedagentic-detection outcome (keeping the "exactly one outcome per run" telemetry invariant), warns, and continues with the install dir as-is.The real auth is retried at bootstrap (
bootstrap.tscallsauthenticateagain), so a transient blip no longer kills the run, while a persistent failure still aborts there — at the true critical point. Users could previously only work around this by passing--project-id.Test plan
project-scope.test.tscovering the auth-failure path: session untouched, no flag fetch, no scan,auth-failedoutcome fired, exception reported.pnpm build, fullproject-scopesuite (11 tests) passing,pnpm lintclean (0 errors).Created with PostHog Code from this inbox report.