Skip to content

fix(ci): clear auth tokens in npm smoke test to prevent WASM SQLite crash - #1278

Merged
MathurAditya724 merged 1 commit into
mainfrom
fix/ci-smoke-test-auth-leak
Jul 22, 2026
Merged

fix(ci): clear auth tokens in npm smoke test to prevent WASM SQLite crash#1278
MathurAditya724 merged 1 commit into
mainfrom
fix/ci-smoke-test-auth-leak

Conversation

@MathurAditya724

Copy link
Copy Markdown
Member

Problem

The Build npm Package (smoke Node 20) job has been failing on main with:

Fatal: SQLite3Error: unable to open database file

Both recent main commits show this failure:

  • b5902f2 (fix(local): Handle standalone span items...)
  • b6e89b5 (fix(init): retry transient auth validation once)

The PRs that merged into main passed CI, but the same code fails on main.

Root Cause

The build-npm job uses environment: production (line 782) so the Bundle step can access SENTRY_AUTH_TOKEN for sourcemap uploads. This token leaks into all subsequent steps in the job.

When the first smoke test runs node dist/bin.cjs --help on Node 20:

  1. The CLI detects SENTRY_AUTH_TOKEN in the environment
  2. It initializes telemetry, which triggers SQLite database initialization
  3. On Node 20, the WASM SQLite fallback driver is used (no node:sqlite before 22.15)
  4. The WASM driver's _nodejs_open fails because the runner's ~/.sentry config directory doesn't exist yet for the switched Node 20 runtime

Why PRs pass but main fails: On PR runs, environment: production resolves to empty (the conditional on line 782 only activates for main / release/* branches), so SENTRY_AUTH_TOKEN is empty. Without a token, the CLI skips telemetry init and never opens the database.

Fix

Explicitly clear SENTRY_AUTH_TOKEN and SENTRY_TOKEN in the first smoke test step's env: block — matching what the deep smoke test step already does (lines 835-836).

This is the minimal, correct fix. The smoke tests are consumer-perspective tests that should run without auth credentials.

…rash

The 'Build npm Package (smoke Node 20)' job has been failing on main with:

  Fatal: SQLite3Error: unable to open database file

Root cause: the build-npm job uses `environment: production` (line 782)
so that the Bundle step can access SENTRY_AUTH_TOKEN for sourcemap uploads.
This token leaks into subsequent steps. When the smoke test runs
`node dist/bin.cjs --help` on Node 20 (WASM SQLite fallback), the CLI
detects the auth token, initializes telemetry, and opens the SQLite
database — but the WASM driver fails because the runner's ~/.sentry
config directory hasn't been set up for the switched Node 20 runtime.

On PR runs, SENTRY_AUTH_TOKEN is empty (the `production` environment is
only activated for main/release branches), so the CLI skips telemetry
init and the smoke test passes. This is why the PR's CI was green but
main's CI is red.

Fix: explicitly clear SENTRY_AUTH_TOKEN and SENTRY_TOKEN in the first
smoke test step, matching what the deep smoke test already does.
@github-actions github-actions Bot added the risk: low PR risk score: low label Jul 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ Patch coverage is 100.00%. Project has 5487 uncovered lines.
✅ Project coverage is 81.69%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    81.69%    81.69%        —%
==========================================
  Files          426       426         —
  Lines        29969     29969         —
  Branches     19496     19496         —
==========================================
+ Hits         24482     24482         —
- Misses        5487      5487         —
- Partials      2046      2043        -3

Generated by Codecov Action

@MathurAditya724
MathurAditya724 merged commit b2b1c9c into main Jul 22, 2026
31 checks passed
@MathurAditya724
MathurAditya724 deleted the fix/ci-smoke-test-auth-leak branch July 22, 2026 14:28
@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-22 14:28 UTC

MathurAditya724 added a commit that referenced this pull request Jul 22, 2026
… crash (#1282)

## Problem

The `Build npm Package (smoke Node 20)` job fails on **main** with:

```
Fatal: SQLite3Error: unable to open database file
```

This persisted after #1278 (which cleared auth tokens but didn't fix the
root cause).

## Root Cause

The WASM SQLite driver (used on Node 20 since `node:sqlite` is
unavailable before 22.15) cannot open the database file at
`~/.sentry/cli.db` when the smoke test runs after switching from Node 22
to Node 20. The runner's home directory state from the Node 22 build
step may include a `~/.sentry` directory with permissions or lock state
incompatible with the WASM driver's Node.js VFS layer (which uses
`fs.openSync`/`mkdirSync` for locking, unlike the native driver).

**Why PRs pass but main fails:** On PR runs, the `production`
environment is not activated (conditional on line 782), so
`SENTRY_AUTH_TOKEN` is empty and the CLI takes a lighter code path. On
main, the token leaks from the Bundle step, causing earlier database
initialization before the `--help` fast path can avoid it.

## Fix

1. **Clear auth tokens** in both smoke test steps (from #1278)
2. **Set `SENTRY_CONFIG_DIR`** to `${{ runner.temp }}/.sentry-smoke` so
the WASM driver creates a fresh database in a known-writable temp
directory, avoiding any state left by the Node 22 build step

This matches the approach used in test infrastructure
(`useTestConfigDir`) — isolate the config directory to prevent
cross-runtime state interference.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: low PR risk score: low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant