Skip to content

Conversation

@s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Jan 15, 2026

In this PR, Nuxt will use the build plugin manager to upload source maps at the end of the build. Currently, it fails because the ignore option is not respected.

injectDebugIds is currently using the "raw" execute function and doesn't pass the --ignore param yet. The functions in the CLI package contain some defaults around what is passed to execute, for example a default ignore:
https://github.com/getsentry/sentry-cli/blob/9f34df859bf2975155aad0fe5c6c423b45c07084/lib/releases/index.ts#L16

The next step is to bring this inject command to the CLI code (CLI PR) so it can be used in the BuildPluginManager.

Related to getsentry/sentry-javascript#18519

@s1gr1d s1gr1d requested review from Lms24 and chargome January 15, 2026 10:49
Comment on lines +417 to +430
export function serializeIgnoreOptions(ignoreValue: string | string[] | undefined): string[] {
const DEFAULT_IGNORE = ["node_modules"];

const ignoreOptions: string[] = Array.isArray(ignoreValue)
? ignoreValue
: typeof ignoreValue === "string"
? [ignoreValue]
: DEFAULT_IGNORE;

return ignoreOptions.reduce(
(acc, value) => acc.concat(["--ignore", String(value)]),
[] as string[]
);
}
Copy link
Member Author

@s1gr1d s1gr1d Jan 15, 2026

Choose a reason for hiding this comment

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

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Sounds reasonable to me. One comment to confirm, otherwise ready to go :)

* Temporary workaround until we expose a function for injecting debug IDs. Currently, we directly call `execute` with CLI args to inject them.
*/
export function serializeIgnoreOptions(ignoreValue: string | string[] | undefined): string[] {
const DEFAULT_IGNORE = ["node_modules"];
Copy link
Member

Choose a reason for hiding this comment

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

hmm I wonder if including node_modules has any implications but I don't think so: We inject debug ids into emitted bundles, meaning the node_modules required by the bundle should already be in there.

Also, the ignore option for upload also defaults to node_modules, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not ignoring it can result in file import loops (this is what happens in e.g. Nuxt).

And yes, it's also the default option for uploading source maps.

? ignoreValue
: typeof ignoreValue === "string"
? [ignoreValue]
: DEFAULT_IGNORE;
Copy link
Member

Choose a reason for hiding this comment

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

Just wondering if we don't always want to add this ignore? In the sense that a user should likely never inject debug ids in node_modules but they usually want to additionally ignore other paths etc. no?

Copy link
Member Author

@s1gr1d s1gr1d Jan 15, 2026

Choose a reason for hiding this comment

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

Good call! I just resembled the existing logic from the CLI here (user-provided value overwrites): https://github.com/getsentry/sentry-cli/blob/a618fb33ddfc3646ac8d5e2391ea1ee6e208b709/lib/releases/index.ts#L159-L161

Either we document, that ignore has a default value of 'node_modules', which gets overwritten or we just always add 'node_modules'. I am leaning towards just better documenting this default value, so it's still possible to overwrite it.

@Lms24 any opinions on that?

Copy link
Member

Choose a reason for hiding this comment

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

So according to this doc, the default is [], which seems like its wrong either way (?).

I am leaning towards just better documenting this default value, so it's still possible to overwrite it.

Me too, because the alternative would be a behaviour break, right? So let's avoid that 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

the default is [], which seems like its wrong either way

In the JS bundler plugins, this is correct. But this value is passed down a bunch of times:

CLI Bundler Plugins Meta-Framework SDK
adds 'node_modules' as default uses CLI in plugin manager (no defaults) uses bundler plugins (no defaults)

Maybe it's worth applying this default in the bundler plugins already, as we could align the behavior better on this stage.

Only the Plugin Manger uses the CLI under the hood, and there are no defaults otherwise.

Copy link
Member Author

Choose a reason for hiding this comment

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

Talked offline, created an issue: #838

@github-actions
Copy link

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Bug Fixes 🐛

Plugin Manager

  • Respect sourcemap.ignore values for injecting debugIDs by s1gr1d in #836
  • Enable "rejectOnError" in debug by s1gr1d in #837

Documentation 📚

  • Add RELEASE.md to document release process by nicohrubec in #834

Build / dependencies / internal 🔧

  • (release) Switch from action-prepare-release to Craft by BYK in #831

🤖 This preview updates automatically when you update the PR.

[
"sourcemaps",
"inject",
...serializeIgnoreOptions(options.sourcemaps?.ignore),
Copy link

Choose a reason for hiding this comment

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

Bug: The injectDebugIds function defaults to ignoring node_modules, but uploadSourcemaps does not, causing source maps to be uploaded without debug IDs.
Severity: HIGH

Suggested Fix

Ensure the uploadSourcemaps function applies the same default ignore behavior as injectDebugIds. When options.sourcemaps?.ignore is undefined, it should default to ignoring ["node_modules"]. This will align the set of files that have debug IDs injected with the set of files that are uploaded as source maps.

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#L561

Potential issue: There is an inconsistency in how default ignore behavior is handled
between `injectDebugIds` and `uploadSourcemaps`. When `options.sourcemaps?.ignore` is
undefined, `injectDebugIds` defaults to ignoring `node_modules`. However,
`uploadSourcemaps` does not apply this default in either its direct upload or prepare
modes. This causes source maps from `node_modules` to be uploaded without the
corresponding debug IDs being injected. As a result, the association between the source
code and the error in Sentry is broken for these files, rendering the uploaded source
maps unusable and wasting upload bandwidth.

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

@s1gr1d s1gr1d merged commit 8e53019 into main Jan 16, 2026
25 checks passed
@s1gr1d s1gr1d deleted the sig/add-ignore-to-inject branch January 16, 2026 09:52
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.

4 participants