Skip to content

fix(cli): Skip a missing directory in sourcemap upload --allow-empty - #2216

Open
sentry-junior[bot] wants to merge 3 commits into
mainfrom
fix/cli-sourcemap-upload-missing-dir-allow-empty
Open

sentry-junior[bot] wants to merge 3 commits into
mainfrom
fix/cli-sourcemap-upload-missing-dir-allow-empty

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

The bundler plugins call sourcemap upload once per build output and pass allowEmpty (getsentry/sentry-javascript#26092). An empty output is skipped, but an output that doesn't exist still throws. That stops the loop, so the outputs after it never upload. CI users moving from sentry-cli v3 hit the same thing: v3 expands each path as a glob, so a path that doesn't exist matches nothing and is skipped.

Rule:

  • With --allow-empty, a missing directory (or a missing glob base, like missing/**) is treated like an empty one. Nothing is uploaded, the output names the directory, and the command exits 0. Org and project aren't needed. The SDK returns { filesUploaded: 0 }, so the plugin's existing "nothing uploaded" warning covers missing and empty outputs together.
  • Without the flag, a missing directory still fails with Directory '<dir>' does not exist. (exit 21). v4 stays strict by default on purpose, to catch a typoed path.
  • Only ENOENT counts as missing. A path that is a file, or one whose stat fails any other way (EACCES, ENOTDIR), still fails even with the flag.

Before (main)

$ SENTRY_ORG=my-org SENTRY_PROJECT=my-project sentry sourcemap upload ./missing --allow-empty
Error: Directory './missing' does not exist.
# exit 21

After

$ SENTRY_ORG=my-org SENTRY_PROJECT=my-project sentry sourcemap upload ./missing --allow-empty
╭────────────────┬───╮
│ Files uploaded │ 0 │
╰────────────────┴───╯

Directory './missing' does not exist, so nothing was uploaded from it.
# exit 0

$ sentry sourcemap upload ./missing --allow-empty --json
{
  "filesUploaded": 0
}

Part of the v3 sourcemap parity work in #1965.

via @betegon, @BYK.

--

View Session [Sentry]

@vercel

vercel Bot commented Nov 12, 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 26, 2026 11:03am UTC
1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Nov 26, 2026 11:03am UTC

Request Review

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 12, 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.

Cursor Bugbot has reviewed your changes 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 16baa37. Configure here.

@github-actions

Copy link
Copy Markdown
Contributor

This PR has had no activity for 3 days. It closes in 2 days unless someone pushes, comments, or adds the WIP label.

sentry-junior Bot and others added 3 commits November 26, 2026 10:36
Bundler plugins upload each build output in turn with allowEmpty. A
build output that does not exist threw and stopped the outputs after it.
--allow-empty now treats a missing directory like an empty one: it
uploads nothing, names the directory, and exits 0. Without the flag, a
missing directory still fails.

Co-Authored-By: bete <28983162+betegon@users.noreply.github.com>
Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
existsSync is false for any stat failure, so an inaccessible path was
skipped under --allow-empty instead of failing.

Co-Authored-By: bete <28983162+betegon@users.noreply.github.com>
Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
A missing glob base is skipped like a missing directory. A path that is
a file, or one whose stat fails with anything but ENOENT (here ENOTDIR),
still fails with the flag. Without the flag, a missing directory fails
with the exact "does not exist" message.

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
@sentry-junior
sentry-junior Bot force-pushed the fix/cli-sourcemap-upload-missing-dir-allow-empty branch from 49d5463 to 78c72e7 Compare November 26, 2026 11:02
@vercel
vercel Bot temporarily deployed to Preview – sentry-local November 26, 2026 11:02 Inactive
@sentry-junior
sentry-junior Bot requested a review from betegon November 26, 2026 11:13
@sentry-junior

sentry-junior Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Changes since the last review:

  • Rebased onto current main (it was ~195 commits behind, including the TypeScript 7 move in build: Move to TypeScript 7, pnpm 12 and a shared strict policy #2266). No conflicts, and the code change itself is unchanged.
  • The Bugbot finding (existsSync treating any stat failure as missing) was already fixed in the ENOENT-only commit. Added tests that pin it down: with --allow-empty, a path that is a file and a path whose stat fails with ENOTDIR both still throw.
  • Added a test for a missing glob base (missing/**) with --allow-empty, which is skipped like a missing directory.
  • The existing test for a missing directory without --allow-empty now checks the exact Directory '<dir>' does not exist. message.
  • Refreshed the PR body: v3 comparison (v3 expands paths as globs, so a missing path matches nothing and is skipped) and the ENOENT-only rule.

This branch was successfully deployed

1 active and 2 inactive (1 outdated) deployments
Preview – cli — 78c72e75 Deployed Nov 26, 2026 by vercel[bot]
Preview – sentry-local — 78c72e75 Deployed Nov 26, 2026 by vercel[bot]
Preview — 49d54634 Deployed Nov 12, 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 Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant