Skip to content

Commit 2a085be

Browse files
chargomeclaude
andauthored
fix(react-router): Pass the project when creating a release (#25089)
The release API rejects a release without a project, and the project given to the `sentry` SDK does not reach `release.create`. Since the move to that SDK (#23398), the Vite plugin logged `[Sentry] Could not create release` on every build; the upload itself still ran, so builds succeeded without a release. The unit test mocked the SDK, so it did not catch it. The plugin now passes the project it already has, as `@sentry/bundler-plugins` does. Same bug in the Remix upload scripts, fixed in #25079. Refs #24989 Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 5fc18dc commit 2a085be

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

‎packages/react-router/src/vite/buildEnd/handleOnBuildEnd.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ export const sentryOnBuildEnd: BuildEndHook = async ({ reactRouterConfig, viteCo
6767
// check if release should be created
6868
if (release?.name) {
6969
try {
70-
await sentry.release.create({ orgVersion: release.name });
70+
// The release API requires a project, and the one given to the SDK does not reach this call.
71+
await sentry.release.create({ orgVersion: release.name, project });
7172
} catch (error) {
7273
// eslint-disable-next-line no-console
7374
console.error('[Sentry] Could not create release', error);

‎packages/react-router/test/vite/buildEnd/handleOnBuildEnd.test.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ describe('sentryOnBuildEnd', () => {
8585
// @ts-expect-error - mocking the React config
8686
await sentryOnBuildEnd(config);
8787

88-
expect(mockSentrySdkInstance.release.create).toHaveBeenCalledWith({ orgVersion: 'v1.0.0' });
88+
expect(mockSentrySdkInstance.release.create).toHaveBeenCalledWith({
89+
orgVersion: 'v1.0.0',
90+
project: 'test-project',
91+
});
8992
});
9093

9194
it('resolves root-level BuildTimeOptionsBase options for release creation and source map upload', async () => {
@@ -115,7 +118,7 @@ describe('sentryOnBuildEnd', () => {
115118
url: undefined,
116119
headers: undefined,
117120
});
118-
expect(mockSentrySdkInstance.release.create).toHaveBeenCalledWith({ orgVersion: '1.2.3' });
121+
expect(mockSentrySdkInstance.release.create).toHaveBeenCalledWith({ orgVersion: '1.2.3', project: 'my-project' });
119122
expect(mockSentrySdkInstance.sourcemap.upload).toHaveBeenCalledWith({
120123
directory: '/build',
121124
release: '1.2.3',

0 commit comments

Comments
 (0)