Skip to content

feat(cli): Authenticate headless installs with setup codes - #1873

Draft
evanpurkhiser wants to merge 1 commit into
git/feat-cli-add-headless-authentication-bootstrap-commandfrom
git/feat-cli-authenticate-headless-installs-with-setup-codes
Draft

evanpurkhiser wants to merge 1 commit into
git/feat-cli-add-headless-authentication-bootstrap-commandfrom
git/feat-cli-authenticate-headless-installs-with-setup-codes

Conversation

@evanpurkhiser

@evanpurkhiser evanpurkhiser commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Depends on #1872. Let headless installs authenticate immediately when SENTRY_SETUP_CODE is supplied. The installer hands authentication to the same bootstrap implementation used by an existing CLI and propagates failures.

https://linear.app/getsentry/issue/VDY-338

Validation on the complete stack: typing, lint, and focused authentication/setup tests pass. The full test run has 21 unrelated failures reproduced on unchanged upstream main in the installer musl-detection, time-range, and zip-writer suites.

Native GitHub Stack: #1874, ordered #1870 → #1871 → #1872 → #1873.

Native bootstrap and shell installation passed against local OAuth redemption using internally generated codes. The shell test used a local artifact mirror for the unreleased binary.

@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sentry-local Ready Ready Preview Nov 3, 2026 7:13pm UTC

Request Review

@linear-code

linear-code Bot commented Nov 3, 2026

Copy link
Copy Markdown

VDY-338

@evanpurkhiser
evanpurkhiser changed the base branch from main to git/feat-cli-bootstrap-account-credentials-from-setup-codes November 3, 2026 18:44
@evanpurkhiser
evanpurkhiser force-pushed the git/feat-cli-authenticate-headless-installs-with-setup-codes branch from 077228e to fa0808c Compare November 3, 2026 18:53
@evanpurkhiser
evanpurkhiser changed the base branch from git/feat-cli-bootstrap-account-credentials-from-setup-codes to git/feat-cli-add-headless-authentication-bootstrap-command November 3, 2026 18:53
@evanpurkhiser
evanpurkhiser added this pull request to stack #1874 November 3, 2026 18:53
@evanpurkhiser
evanpurkhiser force-pushed the git/feat-cli-authenticate-headless-installs-with-setup-codes branch from fa0808c to 99eafe3 Compare November 3, 2026 19:10
import { runInteractiveLogin } from "../../lib/interactive-login.js";
import { interactivePromptsAllowed } from "../../lib/interactive-prompts.js";
import { logger } from "../../lib/logger.js";
import { bootstrapAuthentication } from "../../lib/setup-code.js";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A retained setup code makes later upgrades fail

If SENTRY_SETUP_CODE remains in the environment after installation, later cli setup or upgrade runs inherit it and try to redeem it again; because credentials are already stored, setup throws and the upgrade reports failure. Skip redemption when already authenticated or limit it to fresh installs.

Evidence
  • setup.ts calls bootstrapAuthentication() whenever SENTRY_SETUP_CODE is set, before running configuration steps; setup exposes no --force flag.
  • bootstrapAuthentication() throws when stored credentials exist and force is false, before attempting code redemption.
  • The upgrade path spawns cli setup with the inherited environment (process.env is copied when an install directory is set); a nonzero setup exit becomes an UpgradeError.
  • The setup test covers first-time redemption, but not a subsequent setup or upgrade with the same environment value.

Identified by Warden · code-review · Y2M-JUX

import { runInteractiveLogin } from "../../lib/interactive-login.js";
import { interactivePromptsAllowed } from "../../lib/interactive-prompts.js";
import { logger } from "../../lib/logger.js";
import { bootstrapAuthentication } from "../../lib/setup-code.js";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setup-code login never warms org/completion caches

Redeeming SENTRY_SETUP_CODE stores credentials but never calls warmCachesAfterLogin, and the later warmAttributeCompletions no-ops with an empty org-region cache, unlike the interactive fresh-install login path.

Evidence
  • After setup-code auth succeeds, setup only emits success; it does not call warmCachesAfterLogin().
  • Boolean(getEnv().SENTRY_SETUP_CODE) then returns before the interactive login branch that would call warmCachesAfterLogin().
  • The later warmAttributeCompletions() uses pickWarmupOrgs() → getAllOrgRegions(), which is empty until listOrganizationsUncached() runs; with no orgs it returns immediately.
  • completion-warmup.ts documents that fresh-install login is supposed to warm orgs then attribute keys via warmCachesAfterLogin.

Identified by Warden · code-review · V4K-GBQ

This branch was successfully deployed

1 active deployment
Preview — 99eafe34 Deployed Nov 3, 2026 by vercel[bot]
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