Skip to content

fix(debug-files): a dry run must not fail on a map with no debug-id - #47

Merged
krassx merged 1 commit into
mainfrom
feat/upload-dry-run
Sep 18, 2026
Merged

krassx merged 1 commit into
mainfrom
feat/upload-dry-run

Conversation

@krassx

@krassx krassx commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Item §4 from the CLI-in-JS-flows audit: the whole flow cannot be dry-run. Independent of #45/#46 (different file), so it can merge in any order.

The problem

--dry-run is the documented safe diagnostic, and it could not be used on a freshly built output directory at all:

  • sourcemaps inject --dry-run writes nothing, by design.
  • so every map still has no debug-id,
  • so debug-files upload --type sourcemaps --dry-run exited 11 on the first one.

@bugsee/bundler-plugin-core works around it by skipping the upload step entirely on a dry run — meaning the one safe way to preview the flow never exercises the flow.

The fix

A dry run sends nothing, so an un-keyed map cannot register the unfindable symbol the real run refuses over. It is now reported and counted instead:

$ bugsee-cli sourcemaps inject . --dry-run
INFO injected debug-id path=./app.js debug_id=c33a6517-…
INFO inject complete js_injected=1 … maps_updated=1 dry_run=true

$ bugsee-cli debug-files upload . --type sourcemaps --dry-run …
WARN dry run: no debug_id — `sourcemaps inject` keys it before a real upload path=./app.js.map
WARN dry run: no debug_id — `sourcemaps inject` keys it before a real upload path=./orphan.js.map
INFO dry-run complete: no map carries a debug_id yet — `sourcemaps inject` keys them unkeyed=2 skipped=0
exit 0

$ bugsee-cli debug-files upload . --type sourcemaps …        # real run
exit 11        # unchanged

When NOTHING is keyed, the run completes as a success saying so, rather than falling into the "all 0 source maps are stylesheet or type-declaration maps" branch — plainly the wrong message there, and the one it used to produce.

Unchanged: a real run still exits 11 on the first un-keyed map (uploading it would register a symbol nothing can find), --uuid still keys a map on a dry run, and a dry run still packs everything it can key.

Tests

Three unit tests (real run still refuses + dry run succeeds and packs the keyed map; an entirely un-injected build; --uuid on a dry run) and two e2e flows against the mock server, asserting the warning text and that nothing is posted. Four mutants caught: tolerance removed, tolerance extended to the real run, the all-unkeyed branch bypassed, the counter not incremented.

Gates: cargo fmt --check, clippy --all-targets -D warnings (0), 496 unit tests + all suites, e2e_flows.py ALL PASS.

Follow-on in the JS repo once this is released: @bugsee/bundler-plugin-core can drop its dry-run workaround and preview the real flow.

🤖 Generated with Claude Code

@claude

claude Bot commented Sep 18, 2026

Copy link
Copy Markdown

Code review

debug-files upload --type sourcemaps --dry-run no longer fails on a map with no debug-id: an un-keyed map is now counted (unkeyed) and reported via tracing::warn! instead of erroring, and a dry run where nothing is keyed returns Ok with an accurate log line instead of falling into the (previously misleading) "all N maps are stylesheet maps" branch. The real-run path is untouched (still errors via the same typed input_invalid, still exit 11), the --uuid override path is untouched, and the new logging goes through tracing to stderr, so stdout purity and the exit-code contract both hold.

I traced the full run_sourcemap_upload flow against CLAUDE.md's stdout/exit-code/wire-shape rules and checked the new/changed branches for edge cases (mixed skipped+unkeyed candidates, dry_run with a partially-keyed batch, the --uuid-override bypass) — all behave as documented, and the new unit tests plus the two added e2e flows (sourcemaps_uninjected_dry_run_succeeds, sourcemaps_dry_run_uploads_nothing) exercise exactly the cases described in the PR body. No --help/clap doc drift (no flag or command surface changed), no Cargo.toml/dist/daemon changes in this diff.

Findings: None.

Looks sound — merge as is.

`--dry-run` is documented as the safe diagnostic, and it could not be used on a freshly built output
directory at all. `sourcemaps inject --dry-run` writes nothing by design, so every map still has no
debug-id when the upload preview reaches it — and the upload exited 11 on the first one. The JS
bundler plugin works around this by skipping the upload step entirely on a dry run
(`orchestrate.ts`, with the measurement in its comment), so the one safe way to preview the flow
never exercised the flow.

A dry run sends nothing, so an un-keyed map cannot register the unfindable symbol the real run
refuses over. It is now reported (`dry run: no debug_id — …`) and counted (`unkeyed`) instead. When
NOTHING is keyed, the run completes as a success saying so, rather than falling into the
"all 0 source maps are stylesheet or type-declaration maps" branch — plainly the wrong message
there, and the one it used to produce.

Unchanged: a real run still exits 11 on the first un-keyed map, `--uuid` still keys a map on a dry
run, and a dry run still packs everything it can key.

Verified end to end on a directory with one paired bundle and one orphan map: `inject --dry-run`
reports the id it would write, `upload --dry-run` exits 0 naming both un-keyed maps, and the real
upload still exits 11. Four mutants caught (tolerance removed, tolerance extended to the real run,
the all-unkeyed branch bypassed, the counter not incremented). Two new e2e flows.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@krassx
krassx force-pushed the feat/upload-dry-run branch from 1500e60 to a295e0f Compare September 18, 2026 15:58
@claude

claude Bot commented Sep 18, 2026

Copy link
Copy Markdown

Code review

Makes debug-files upload --type sourcemaps --dry-run report un-keyed maps (unkeyed counter + a tracing::warn!) instead of failing on the first one, so the documented SAFE diagnostic actually works on a freshly built, uninjected directory; a real (non-dry) run still exits 11 on the first un-keyed map, unchanged. Traced through the logic carefully (the planned.is_empty() branch, the interaction with the pre-existing stylesheet-only-maps error path, and the final dry-run complete log) and it holds together: unkeyed is only ever nonzero on a dry run, the stylesheet-only-maps case is untouched (still fails loudly in both modes, per the existing test), and --uuid still overrides as before. New unit tests cover the three relevant cases, and the e2e script + README/CHANGELOG were updated consistently with the code. No stdout writes were added (all new messages go through tracing to stderr), no exit-code meanings changed, and no wire-format/JSON output is touched.

Findings: None.

Looks sound — merge as is.

@krassx
krassx merged commit c1f942e into main Sep 18, 2026
18 checks passed
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.

1 participant