Skip to content

fix(cli): harden ported wizard codemods against real-world project shapes - #2565

Open
sentry-junior[bot] wants to merge 11 commits into
feat/cli-wizard-sveltekit-remix-react-routerfrom
feat/cli-wizard-port-review-fixes
Open

sentry-junior[bot] wants to merge 11 commits into
feat/cli-wizard-sveltekit-remix-react-routerfrom
feat/cli-wizard-port-review-fixes

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #2526. It fixes the Warden and Bugbot findings on that PR where the fix changes the wizard's behaviour relative to upstream getsentry/sentry-wizard (v9.1.0).

Behaviour changes vs upstream sentry-wizard

  • React Router handleError (function export, error-only params): binds request from the handler's parameters, adding { request } when needed. Upstream used request unbound, so the handler threw. (CC6-JTR)
  • React Router handleError (const or arrow export): Sentry.captureException now goes first in the body, as it already did for function exports, so an early return no longer skips it. (6BK-CX9)
  • React Router handleError (named second parameter): the guard reads args.request / context.request from the existing parameter instead of assuming a destructured request.
  • React Router vite.config: sentryReactRouter(…, <env>) gets the defineConfig callback's own parameter, with or without a default. If there is none, or it is destructured (({ mode })), the wizard picks a name nothing in the file uses yet (config, then configEnv). A destructured parameter is destructured again in the body and keeps its default. Upstream always passed config. (NTK-WRA)
  • React Router start script: keeps the project's own command and adds NODE_ENV=production NODE_OPTIONS='--import ./instrument.server.mjs' in front of it. Upstream replaced any start script without NODE_OPTIONS with react-router-serve ./build/server/index.js. A default project gets the same command as before. (55R-DRR)
  • React Router NODE_OPTIONS merge: an unquoted value ends at the first whitespace, as in a shell. The import is merged in before any command (e.g. pm2), and sibling variables like PORT=3000 stay separate. Upstream allowlisted commands and absorbed the following tokens. (QRC-596)
  • Remix root export { ErrorBoundary }: the existing boundary is found and instrumented. Upstream added a duplicate ErrorBoundary. (X9W-F69)
  • Remix root export const ErrorBoundary: arrow and function-expression boundaries are instrumented, and an expression body becomes a block body. Upstream left them unchanged. (SFV-22K)
  • Remix root capture: captureRemixErrorBoundaryError(<name>) goes right after the useRouteError() read (also useRouteError() as Error or useRouteError()!) and uses the boundary's own binding (e.g. routeError). Upstream used error before the last statement. (UWP-WMX)
  • Remix root, boundary not resolvable (e.g. export const ErrorBoundary = withX(…)): the wizard warns with the line to add. Upstream skipped it silently.
  • Remix handleError: wraps the existing handler as a whole (Sentry.wrapHandleErrorWithSentry(<original>)), which keeps async, parameters, expression bodies and handlers built elsewhere. Upstream copied the body into a fixed non-async arrow, or threw on expression bodies. (7JW-LJX, 484-EKL)
  • Remix example page: also writes app/routes/api.sentry-example-api.(ts|js), the route the page's button fetches. Upstream never created it, so the button got a 404. (HTF-GHR)
  • Remix custom Express server: the instrumentation import is relative to the server file (../instrumentation.server.mjs from server/index.ts). Upstream always used ./. (QPF-CJ8)
  • SvelteKit Svelte 5 example page: isConnected uses $state(true), so the connectivity warning and the disabled button update. (XYK-TL6)

Product calls

  • The start script keeps the user's command. For a default react-router-serve ./build/server/index.js project, the result matches the React Router manual setup docs.
  • The Remix handleError output is the Sentry.wrapHandleErrorWithSentry(...) form from the Remix manual setup docs, wrapped around the user's own handler.
  • The Remix example API route uses the same loader shape as the React Router wizard's route, at the path the Remix example page already fetches.

via @BYK.

--

View Session [Sentry]

…apes

React Router:
- handleError: report before the handler's own code runs, for both function
  and const exports, and bind `request` from the handler's own parameters.
- vite: pass the defineConfig callback's own config env to sentryReactRouter.
- package.json: keep the project's start command and merge NODE_OPTIONS with
  shell semantics instead of replacing the command.

Remix:
- root: find `export { ErrorBoundary }` and `export const ErrorBoundary`
  boundaries, and capture under the name useRouteError is bound to.
- handleError: wrap the whole existing handler so async and params survive.
- example page: create the /api/sentry-example-api route it fetches.
- custom Express servers: import the instrumentation file relative to the
  server file.

SvelteKit:
- Svelte 5 example page: make isConnected reactive with $state.
@sentry-junior
sentry-junior Bot requested a review from BYK November 27, 2026 17:20
@sentry-junior
sentry-junior Bot added this pull request to stack #2566 November 27, 2026 17:20
@vercel

vercel Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
cli Ready Ready Preview Nov 27, 2026 11:27pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Nov 27, 2026 11:27pm UTC

Request Review

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 27, 2026

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

sentry-junior Bot and others added 2 commits November 27, 2026 22:05
…react-router' into feat/cli-wizard-port-review-fixes

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
- vite: the added config env parameter uses a name nothing in the file uses
  yet (config, then configEnv, ...), and defaulted parameters such as
  `({ mode } = {})` or `(env = {})` are handled.
- Remix root: `useRouteError() as Error` and `useRouteError()!` count as the
  boundary's existing error read.

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@BYK
BYK enabled stacked auto-merge November 27, 2026 22:59
…/cli-wizard-port-review-fixes

# Conflicts:
#	packages/cli/test/lib/wizard/react-router/sdk-setup.test.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e957aca. Configure here.

/NODE_OPTIONS=([^\s]+(?:\s+[^\s]+)*?)(\s+(?:react-router-serve|react-router|node|npx|tsx))/,
`NODE_OPTIONS='${mergedOptions}'${commandPart}`,
nodeOptions[0],
() => `${nodeOptions[1] ?? ""}NODE_OPTIONS='${mergedOptions}'`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Quoted NODE_OPTIONS can break scripts

Low Severity

The new NODE_OPTIONS matcher accepts a double-quoted value that contains single quotes, then always rewrites it as a single-quoted string. That closes the quote early and can split or drop the original options, so the merged --import never reaches Node.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e957aca. Configure here.

This branch was successfully deployed

1 active and 1 inactive deployments
Preview – cli — 0806fdb1 Deployed Nov 27, 2026 by vercel[bot]
Preview – sentry-local — 0806fdb1 Deployed Nov 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant