Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/bundler-plugin-core/src/build-plugin-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ export function createSentryBuildPluginManager(
const cliInstance = createCliInstance(options);
await cliInstance.execute(
["sourcemaps", "inject", ...buildArtifactPaths],
options.debug ?? false
options.debug ? "rejectOnError" : false
);
Comment on lines 556 to 559
Copy link

Choose a reason for hiding this comment

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

Bug: The cliInstance.execute() method is called with the string "rejectOnError" when options.debug is true, but this method's second parameter expects a boolean, which will cause a runtime error.
Severity: HIGH

Suggested Fix

Replace the ternary expression options.debug ? "rejectOnError" : false with a boolean value. The correct implementation should be !!options.debug or simply options.debug if it's guaranteed to be a boolean.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: packages/bundler-plugin-core/src/build-plugin-manager.ts#L556-L559

Potential issue: The `cliInstance.execute()` method from the `@sentry/cli` package is
called with an incorrect argument type. When `options.debug` is true, the code passes
the string `"rejectOnError"` as the second argument. However, the method's signature is
`execute(args: string[], live: boolean)`, which requires a boolean value. While the
`uploadSourceMaps` method accepts the string `"rejectOnError"`, the `execute` method
does not. This will cause a runtime error when the bundler plugin is run in debug mode,
preventing debug ID injection from succeeding.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Member

Choose a reason for hiding this comment

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

looks like this is only true for v3 of the CLI 🤔
https://github.com/getsentry/sentry-cli/blob/2.58.4/lib/index.js#L79

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, the default handling of live changed in v3

} catch (e) {
sentryScope.captureException('Error in "debugIdInjectionPlugin" writeBundle hook');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ describe("createSentryBuildPluginManager", () => {
);
});

it("should pass debug flag when options.debug is true", async () => {
it('should pass "rejectOnError" flag when options.debug is true', async () => {
mockCliExecute.mockResolvedValue(undefined);

const buildPluginManager = createSentryBuildPluginManager(
Expand All @@ -460,7 +460,7 @@ describe("createSentryBuildPluginManager", () => {

expect(mockCliExecute).toHaveBeenCalledWith(
["sourcemaps", "inject", "/path/to/bundle"],
true
"rejectOnError"
);
});
});
Expand Down
13 changes: 2 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8109,15 +8109,6 @@ istanbul-reports@^3.1.3:
html-escaper "^2.0.0"
istanbul-lib-report "^3.0.0"

jackspeak@^2.0.3:
version "2.2.1"
resolved "https://registry.npmjs.org/jackspeak/-/jackspeak-2.2.1.tgz#655e8cf025d872c9c03d3eb63e8f0c024fef16a6"
integrity sha512-MXbxovZ/Pm42f6cDIDkl3xpwv1AGwObKwfmjs2nQePiy85tP3fatofl3FC1aBsOtP/6fq5SbtgHwWcMsLP+bDw==
dependencies:
"@isaacs/cliui" "^8.0.2"
optionalDependencies:
"@pkgjs/parseargs" "^0.11.0"

jackspeak@^3.1.2:
version "3.4.3"
resolved "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz#8833a9d89ab4acde6188942bd1c53b6390ed5a8a"
Expand Down Expand Up @@ -9608,7 +9599,7 @@ minimatch@^8.0.2:
dependencies:
brace-expansion "^2.0.1"

minimatch@^9.0.0, minimatch@^9.0.1:
minimatch@^9.0.0:
version "9.0.1"
resolved "https://registry.npmjs.org/minimatch/-/minimatch-9.0.1.tgz#8a555f541cf976c622daf078bb28f29fb927c253"
integrity sha512-0jWhJpD/MdhPXwPuiRkCbfYfSKp2qnn2eOc279qI7f+osl/l+prKSrvhg157zSYvx/1nmgn2NqdT6k2Z7zSH9w==
Expand Down Expand Up @@ -10764,7 +10755,7 @@ path-scurry@^1.11.1:
lru-cache "^10.2.0"
minipass "^5.0.0 || ^6.0.2 || ^7.0.0"

path-scurry@^1.6.1, path-scurry@^1.7.0:
path-scurry@^1.6.1:
version "1.9.2"
resolved "https://registry.npmjs.org/path-scurry/-/path-scurry-1.9.2.tgz#90f9d296ac5e37e608028e28a447b11d385b3f63"
integrity sha512-qSDLy2aGFPm8i4rsbHd4MNyTcrzHFsLQykrtbuGRknZZCBBVXSv2tSCDN2Cg6Rt/GFRw8GoW9y9Ecw5rIPG1sg==
Expand Down
Loading