Skip to content

fix(config,bundle): empty env vars + atomic bundle re-commit#8

Open
SahilRakhaiya05 wants to merge 2 commits into
TestSprite:mainfrom
SahilRakhaiya05:fix/config-empty-env-vars
Open

fix(config,bundle): empty env vars + atomic bundle re-commit#8
SahilRakhaiya05 wants to merge 2 commits into
TestSprite:mainfrom
SahilRakhaiya05:fix/config-empty-env-vars

Conversation

@SahilRakhaiya05

@SahilRakhaiya05 SahilRakhaiya05 commented Jun 23, 2026

Copy link
Copy Markdown

Summary

1. Empty env vars treated as unset (loadConfig)

When TESTSPRITE_API_URL or TESTSPRITE_API_KEY is set but empty/whitespace (e.g. export TESTSPRITE_API_URL= in a shell profile), runtime commands no longer resolve to a broken empty endpoint or ignore stored credentials. Matches the normalization already used in auth configure.

2. Bundle re-commit preserves prior complete bundle (commitBundle)

Re-running test failure get --out <dir> used to delete meta.json and wipe steps/ before the new bundle landed. A failed mid-commit (expired presigned URL, disk error, etc.) left the directory with no usable bundle.

Fix: Build the complete bundle in <dir>/.tmp/, then atomically swap via directory rename. The prior bundle is moved aside and only deleted after success; failed swaps roll back.

Testing

  • npx vitest run src/lib/config.test.ts - 11 passed
  • npx vitest run src/lib/bundle.commit.test.ts - rollback regression
  • npx vitest run src/commands/test.test.ts -t runFailureGet - 13 passed
  • npm run typecheck and npm run lint - pass

Files changed:

  • src/lib/config.ts, src/lib/config.test.ts, src/commands/auth.ts
  • src/lib/bundle.ts, src/lib/bundle.commit.test.ts

Empty or whitespace-only TESTSPRITE_API_URL / TESTSPRITE_API_KEY values (e.g. export TESTSPRITE_API_URL= in a shell profile) no longer short-circuit the resolution chain. Runtime commands now fall through to the credentials file and prod default, matching auth configure behavior.

Also normalize the auth whoami dry-run endpoint resolution path.
Replace in-place commitBundle file renames with a directory-level atomic swap. The complete staging tree is moved aside, the prior bundle is only deleted after a successful rename, and failed swaps roll back to the previous meta.json and steps/ contents.

Adds commitBundle regression test in bundle.commit.test.ts.
@SahilRakhaiya05 SahilRakhaiya05 changed the title fix(config): treat empty env vars as unset in loadConfig fix(config,bundle): empty env vars + atomic bundle re-commit Jun 23, 2026
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