Repository navigation
fix(cli): instrument new Cloudflare workers and harden the Wrangler flow - #2563
Open
sentry-junior[bot] wants to merge 50 commits into
Open
sentry-junior[bot] wants to merge 50 commits into
sentry-junior[bot] wants to merge 50 commits into
Conversation
Start moving getsentry/sentry-wizard into the CLI as `sentry wizard`. This adds the command with the `@sentry/wizard` integrations and flags (`-i`, `--url`, `--org`, `--project`, `--saas`, `--spotlight`, and the rest), the shared wizard helpers, and the Next.js flow. The other integrations report that they are not available in this version yet. The wizard logs in with the CLI's own login: a stored `sentry auth login` session, an agent handoff, or the device flow, instead of the `account/settings/wizard/<hash>` browser flow. It then picks or creates the project, reads its DSN, and creates an org auth token for source map uploads. Telemetry goes through the CLI's client. `sentry init` stays the agent setup guide; its help now points to `sentry wizard` for the interactive setup. Co-Authored-By: BYK <[email protected]>
Port `ast-utils` and `url` from getsentry/sentry-wizard into `src/lib/wizard/utils/`. The SvelteKit, Remix, React Router, Angular, Nuxt, source maps, Cloudflare, React Native and Android wizards all use them, so they land once here and the platform PRs that follow build on them in parallel. `ast-utils` edits recast ASTs, so recast and ast-types become direct dev dependencies; both already came in through magicast. Co-Authored-By: BYK <[email protected]>
`sentry wizard` logs in with the CLI's login, which has no sign-up or partner step, so `--signup`, `--promo-code` and `--coming-from` no longer do anything. Passing one now fails with a message that points to https://sentry.io/signup/ instead of being accepted silently. `promoCode` and `comingFrom` leave `WizardOptions`, the welcome banner and `setupCI`, which loses its Vercel partner branch. The help text and the docs say which `@sentry/wizard` flags were removed. Co-Authored-By: BYK <[email protected]>
…st-helpers Co-Authored-By: BYK <[email protected]>
Port the source maps wizard (all build tools) and the Cloudflare Workers wizard from sentry-wizard 9.1.0 into `sentry wizard`, with their tests, and register `sourcemaps` and `cloudflare` in WIZARD_RUNNERS. The generated projects now use the v4 `sentry` CLI instead of sentry-cli v2: the wizard installs the `sentry` npm package and writes `sentry sourcemap inject/upload` and `sentry release create` scripts. `.sentryclirc` stays, since v4 still reads it. A self-hosted URL is passed in `SENTRY_URL`, which replaced the sentry-cli `--url` flag. `sourcemaps/ci.ts` gains the step that asks to run the `sentry:sourcemaps` script in CI. The Cloudflare test fixtures keep their upstream bytes, so the formatter, linter and test typecheck skip wizard fixtures. Co-Authored-By: BYK <[email protected]>
…sourcemaps-cloudflare Picks up the removed sign-up and partner flags. The source maps and Cloudflare wizards no longer pass `promoCode` to `printWelcome`, and `setupCI` loses the `comingFrom` argument. The `sourcemaps/ci.ts` conflict is resolved to the shared version from #2525. Co-Authored-By: BYK <[email protected]>
Generated `sentry` commands no longer pass the hidden `--org` and `--project` compat flags. The generic and Wrangler source maps flows merge `org` and `project` into the project's `.sentryclirc` `[defaults]`, next to the existing `[auth] token` and any other keys, and v4 reads them from there. Wrangler's `sentry:sourcemaps` script drops the `SENTRY_URL=` prefix and the flags from `sentry release create` and `sentry sourcemap upload`. The self-hosted URL is not written to the file. v4 only trusts a non-SaaS `[defaults] url` when the token's host or a stored login vouches for it, and a token from the same file does not, so the upload would be refused. Self-hosted users are told to set `SENTRY_URL` instead. `setupCI` gets the upload target, so the CI step lists `SENTRY_AUTH_TOKEN`, `SENTRY_ORG`, `SENTRY_PROJECT` and, for self-hosted, `SENTRY_URL`. Wrangler counts as a `sentry`-command tool there (its token lives in `.sentryclirc`), but skips the "run the script in CI" prompt, since its `post<deploy>` script already runs it. `sentry@^4` is installed as a devDependency. `sourcemaps/ci.ts`, `sourcemaps/tools/sentry-cli.ts`, `angular.ts`, `types.ts` and `abort-if-sportlight-not-supported.ts` now match #2525, apart from exporting `addOrgAndProjectToSentryCliRc` for Wrangler, the devDependency install, and the Wrangler CI case. Co-Authored-By: BYK <[email protected]>
The Cloudflare wizard fixtures are upstream sentry-wizard Worker sources that `wrap-worker` and `update-wrangler-config` tests read and compare as text. The test tsconfig excludes them, so the tsconfig policy check needs them in its list of files no type check covers on purpose.
- Skip the `.sentryclirc` URL check, like `sentry init`: the wizard picks its instance (`--url`, `--saas` or a prompt) before it logs in. - Use the stored login's instance for `sentryUrl` when none was chosen, and log in again when the stored login is for another instance. - Link self-hosted users to `/settings/<org>/auth-tokens/`. - Leave an unparseable MCP config alone (show the copy-paste fallback), and let a cancel inside the MCP setup stop the wizard. - Resolve `catalog:` and `catalog:default` against both pnpm default catalog forms. - Find an existing `SENTRY_AUTH_TOKEN` after the comment header of `.env.sentry-build-plugin`, so re-runs don't add a second one. - Run Windows formatters with Node in the standalone binary, where `process.execPath` is `sentry`. - Ask before updating an `@sentry/nextjs` listed in devDependencies, and treat an unknown SDK version as the `^11` the wizard installs. Co-Authored-By: BYK <[email protected]>
…st-helpers Co-Authored-By: BYK <[email protected]>
On self-hosted Sentry, the generic and Wrangler source maps flows now write `url` to `.sentryclirc` `[defaults]` next to `org` and `project`. v4 rejects that URL from the same file as the token today. The trust check fix is separate, and the generated script depends on it. The CI step on sentry.io now lists only `SENTRY_AUTH_TOKEN`. On self-hosted Sentry it also lists `SENTRY_ORG`, `SENTRY_PROJECT` and `SENTRY_URL`. The wizard docs fragment says the same. Co-Authored-By: BYK <[email protected]>
Address review feedback on the shared wizard helpers: - Enable unicorn/no-array-for-each repo-wide and convert every .forEach call site to for...of, including getLastRequireIndex. - Add buildProjectIssuesUrl to lib/sentry-urls.ts, built on getOrgBaseUrl like buildEventSearchUrl, and delete the wizard-specific wizard/utils/url.ts. - Move findFile into lib/dsn/fs-utils.ts and build it on isRegularFile, so a directory or FIFO with a matching name is skipped. It is async now. Co-Authored-By: BYK <[email protected]>
`sentry wizard [<org>/<project>] [<integration>]` replaces the `@sentry/wizard` flags, with the target first like other commands. - The integration is a positional, one at a time. A bare integration id is never read as a target, and a single bare word is always read as an integration, so a project or org spelled like one is written `my-org/nextjs`, `nextjs/` or `/nextjs`. - The target parses with the CLI's org/project grammar and resolves after login with `resolveOrgOptionalTarget`, like other commands. Without one the org and project pickers run, with no detection. - `-f/--force` is the only flag. It sets both `forceInstall` and `ignoreGitChanges`. - The instance comes from `SENTRY_URL` or the stored login, so the SaaS/self-hosted prompt, `--url`, `--saas` and `skipRcUrlCheck` go. - Spotlight mode follows `SENTRY_SPOTLIGHT`, telemetry follows `isTelemetryEnabled()`, and debug output goes through the CLI logger (`--verbose`, `--log-level`). - Every other `@sentry/wizard` flag and `SENTRY_WIZARD_*` variable is gone, hidden ones included, with `disableTelemetryForRun` and `rejectRemovedFlags`. A test pins the wizard's own flags to `force`, and `check:env-coverage` (part of `ci:policy`) fails when any file under `src/` names `SENTRY_WIZARD_`. Co-Authored-By: BYK <[email protected]>
Re-export buildProjectIssuesUrl from lib/sentry-web-urls.ts through withSentryBaseUrl(getApiBaseUrl()), like the other user-facing link builders, so self-hosted and regional logins get links on the host they are authenticated against. Co-Authored-By: BYK <[email protected]>
Co-Authored-By: BYK <[email protected]>
…eat/cli-wizard-shared-ast-helpers Co-Authored-By: BYK <[email protected]>
…izard base Merges origin/feat/cli-wizard-shared-ast-helpers at f0a48de (#2520, the chart-app fix and #2519's positional rework) and fixes what it breaks: - `runWizard` no longer takes `debug`, so the redirect to another wizard drops it. - `wizard/utils/url.ts` is gone. The source maps outro links to the project's issues with `buildProjectIssuesUrl` from `lib/sentry-web-urls`. - `findFile` now comes from `lib/dsn/fs-utils` and is async, so the tsc, Vite and webpack tools await it. - The new `no-array-for-each` lint rule: two `forEach` loops become `for...of`. - The wizard docs fragment keeps the base's flag table and the source maps paragraph from this branch. Co-Authored-By: BYK <[email protected]>
…already runs it When the production build script already ends with `sentry:sourcemaps`, `addSentryCommandToBuildCommand` left `addedToBuildCommand` false, so `setupNpmScriptInCI` still asked for a separate CI step and the upload would run twice. That branch now sets the flag too. Co-Authored-By: BYK <[email protected]>
Takes `sourcemaps/tools/sentry-cli.ts` and its test from #2525 (f5ca46e) as they are, so both PRs carry the same copy. Its `.sentryclirc` writer is `addUploadTargetToSentryCliRc`, so the Wrangler tool and the `.sentryclirc` defaults test call it by that name. Co-Authored-By: BYK <[email protected]>
…emaps-cloudflare Co-Authored-By: BYK <[email protected]> # Conflicts: # apps/cli-docs/src/fragments/commands/wizard.md # packages/cli/src/lib/wizard/run.ts # packages/cli/src/lib/wizard/sourcemaps/ci.ts # packages/cli/src/lib/wizard/utils/project-data.ts # packages/cli/test/lib/wizard/utils/project-data.test.ts # scripts/tsconfig-policy.test.mjs
Takes `sourcemaps/tools/sentry-cli.ts`, `sourcemaps/tools/angular.ts` and their tests from #2525 (370f74d) unchanged, so both PRs carry the same copies. This brings in the Angular snippet that sets `sourceMap` in the production configuration and the `forceInstall` option for the `sentry` install. Co-Authored-By: BYK <[email protected]>
Fixes bugs carried over from sentry-wizard 9.1.0 that Warden and Bugbot found on review, without changing how the flows work: - Cloudflare: offer the data collection prompt when the installed SDK version is unknown, using the `^11` range the wizard installs - Cloudflare: stop the TOML `main` match at the closing quote - Vite: recognize quoted `build` and `sourcemap` keys, using the shared `getObjectProperty` helper - Webpack: link the webpack docs when creating a new config - Create React App: name the `GENERATE_SOURCEMAP` variable, and detect CRA from `react-scripts` - Wrangler: exit when the user keeps an existing `sentry:sourcemaps` script, as the prompt says, and read `--outdir` values after several spaces
Changes how the ported source maps and Cloudflare wizards behave where sentry-wizard 9.1.0 left a project half set up: - Cloudflare: create a missing entry point where Wrangler's `main` points, and wrap new and existing workers with `Sentry.withSentry()` - Cloudflare: show `main` in the wrangler.toml snippet when it is added - webpack: keep a non-array `plugins` value by spreading it - Wrangler: keep an existing `post<deploy>` script, chain the upload onto the deploy script for Yarn 2+, and still set up the upload script and CLI config when no deploy script is picked - Wrangler: edit deploy scripts that run wrangler through npx, pnpm exec, yarn, bunx, or cross-env, and show the flags to add when it can't - Source maps: offer the SvelteKit or React Native wizard only when this version has it
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
…zard-sourcemaps-cloudflare-fixes
An empty `main` in wrangler.json(c) was returned as the entry point, so the wizard tried to wrap the project directory while the config update wrote `src/index.ts`, a file it never created. Return undefined, as the TOML branch already does, so the starter worker goes to `src/index.ts`.
…emaps-cloudflare # Conflicts: # packages/cli/src/lib/wizard/run.ts # scripts/tsconfig-policy.test.mjs
…zard-sourcemaps-cloudflare-fixes
The wizard installed `sentry@^4`, which matches no published version, so source map setup stopped after the SDK and config changes. Install the major of the running CLI instead (`[email protected]` today), with no shell metacharacters, since installPackage runs the package manager through a shell.
…zard-sourcemaps-cloudflare-fixes
The Wrangler flow still installed `sentry@^4`, which matches no published version, and `^` is a shell metacharacter for installPackage. Use SENTRY_CLI_PACKAGE_SPEC, as the generic flow does.
…zard-sourcemaps-cloudflare-fixes # Conflicts: # packages/cli/src/lib/wizard/sourcemaps/tools/wrangler.ts # packages/cli/test/lib/wizard/sourcemaps/tools/wrangler-flow.test.ts
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 61f2654. Configure here.
The wizard logged "Wrapped … with Sentry initialization" whenever wrapWorkerWithSentry returned, including when Sentry was already set up and the wrap was skipped, and when the file had no default export, where it only added an unused import. Return whether it wrapped, and throw for a file with no default export, leaving it unchanged, so the wizard shows the manual wrap instructions instead.
…'t be edited When the wizard can't add the source map flags to the chosen deploy script, it shows a manual `wrangler deploy` command. For Yarn 2+, which doesn't run `post` scripts, it still chained the upload onto that same script, so replacing the script with the manual command dropped the upload. For Yarn 2+, leave the script alone and end the manual command with the upload instead.
Base automatically changed from
feat/cli-wizard-sourcemaps-cloudflare
to
main
November 28, 2026 01:07
…emaps-cloudflare-fixes Co-Authored-By: BYK <[email protected]> # Conflicts: # packages/cli/src/lib/wizard/cloudflare/cloudflare-wizard.ts # packages/cli/src/lib/wizard/cloudflare/sdk-setup.ts # packages/cli/src/lib/wizard/cloudflare/templates.ts # packages/cli/src/lib/wizard/cloudflare/wrangler/get-entry-point-from-wrangler-config.ts # packages/cli/src/lib/wizard/cloudflare/wrangler/update-wrangler-config.ts # packages/cli/src/lib/wizard/cloudflare/wrap-worker.ts # packages/cli/src/lib/wizard/sourcemaps/ci.ts # packages/cli/src/lib/wizard/sourcemaps/tools/webpack.ts # packages/cli/src/lib/wizard/sourcemaps/tools/wrangler.ts # packages/cli/src/lib/wizard/sourcemaps/utils/other-wizards.ts # packages/cli/test/lib/wizard/cloudflare/__snapshots__/wrap-worker.test.ts.snap # packages/cli/test/lib/wizard/cloudflare/cloudflare-wizard.test.ts # packages/cli/test/lib/wizard/cloudflare/get-entry-point-from-wrangler-config.test.ts # packages/cli/test/lib/wizard/cloudflare/sdk-setup.test.ts # packages/cli/test/lib/wizard/cloudflare/update-wrangler-config.test.ts # packages/cli/test/lib/wizard/cloudflare/wrap-worker.test.ts # packages/cli/test/lib/wizard/sourcemaps/tools/webpack.test.ts # packages/cli/test/lib/wizard/sourcemaps/tools/wrangler-flow.test.ts # packages/cli/test/lib/wizard/sourcemaps/tools/wrangler.test.ts
This branch was successfully deployed
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.

Follow-up to #2529 (merged): behaviour changes against upstream sentry-wizard 9.1.0.
Behaviour changes against sentry-wizard 9.1.0
mainfile (SHJ-RG7): when Wrangler'smainpoints to a file that doesn't exist, the wizard creates the starter worker there and wraps it. Upstream skipped setup silently and still reported success.main(YBF-MLA): the starter worker written tosrc/index.tsis now wrapped withSentry.withSentry(). Upstream wrote a plain worker with no Sentry.src/index.tswith nomain: the existing file is wrapped instead of being overwritten by the starter worker.maininwrangler.json: treated as nomain, so the starter worker goes tosrc/index.ts, which the config then points to. Upstream tried to wrap the project directory and pointed the config at a file it never created.export default, the file is left unchanged and the manual wrap instructions show. Upstream reported the wrap in both cases, and added an unused Sentry import to a file with no default export.wrangler.toml(WHX-UYU): the copy-paste snippet includesmain = "src/index.ts"when the wizard setsmain. Upstream left it out.plugins(UNB-FTW):plugins: existingPluginsorplugins: getPlugins()becomes[...existingPlugins, sentryWebpackPlugin(…)]. Upstream replaced the value and dropped those plugins.undefinedandnullare still replaced.post<deploy>(5YD-7F8): an existingpost<deploy>script is kept, with&& <pm> sentry:sourcemapsadded after it. Upstream overwrote it. It's left alone when it already runssentry:sourcemaps.postscripts, so the upload is chained onto the deploy script (&& yarn sentry:sourcemaps). npm, pnpm, Yarn 1 and Bun keep thepost<deploy>hook. When the wizard can't edit the deploy script, it leaves that script alone and ends the manual deploy command with the upload instead.sentry:sourcemaps, the.sentryclircupload target and the auth token, then shows the deploy command to add. Upstream stopped before writing any of them and still reported success.npx,pnpm,yarnorbunxcomes straight beforewrangler deployare now edited. Upstream accepted only a barewrangler deploy. Any other form, such as runner flags (-y,-C,--cwd),pnpm exec/dlx,bun x,wrangler@<version>,cross-envor a leadingVAR=value, gets the manual instructions.wrangler deploywith the--outdir,--var SENTRY_RELEASE:…and--upload-source-mapsflags. Upstream showed the unchanged script.ValidationErroronce the redirect is accepted. SvelteKit shows up again on its own once its runner lands..jsor.mjsmain: the starter worker written there is plain JavaScript. Only TypeScript entry points get the typed starter.wrangler deploycommand, not on earlier text that matches it, such asecho Running wrangler deploy. Upstream edited the first match.SENTRY_RELEASEdoesn't get a second--var SENTRY_RELEASE:…. Upstream added one on every run.compatibility_date: the Worker's date is kept, and today's date is only added when the config has none. The TOML snippet marks it "only if not set yet". Upstream always overwrote it with today's date.pages deployandversions deploy: these aren't treated as a Workers deploy, bare or through a runner, so they don't get the Workers-only flags that would break them. The wizard shows the manual instructions instead. Upstream edited a barewrangler pages deployorwrangler versions deploy.Product calls
withSentry: follows the Wrangler install guide and the existing wrap path for configured entry points.post<deploy>hook, merged rather than overwritten: the Wrangler source maps guide uses apostdeployhook, so that stays the default. An existing hook is kept, the way the other flows keep user scripts.&&chaining for Yarn 2+ only: matches how the sentry-cli flow attachessentry:sourcemapsto the build script. Other package managers keep the hook from the docs.npx/pnpm/yarn/bunxdeploy commands: the new flags go after thewrangler deploysegment, as they do for a bare command.via @BYK.
--
View Session [Sentry]