Skip to content

fix(rerun): preserve exit code and escalate auth errors in batch rerun#33

Open
crypticsaiyan wants to merge 1 commit into
TestSprite:mainfrom
crypticsaiyan:fix/rerun-exitcode-key-overflow
Open

fix(rerun): preserve exit code and escalate auth errors in batch rerun#33
crypticsaiyan wants to merge 1 commit into
TestSprite:mainfrom
crypticsaiyan:fix/rerun-exitcode-key-overflow

Conversation

@crypticsaiyan

@crypticsaiyan crypticsaiyan commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

runTestRerun's pollAccepted hardcoded exitCode: 1 on every ApiError during run polling. The batch aggregator detects auth failures via rerunResults.find(r => r.error?.exitCode === 3). With every error stored as exitCode: 1, auth errors were never escalated and the batch always exited 1 instead of 3.

The sibling function runTestRunAll already had both fixes applied. runTestRerun missed them.

The Fix

  • Exit Code Preservation: pollAccepted now stores exitCode: err.exitCode instead of hardcoded 1, so the aggregator sees the real error class from each polling failure.
  • Auth Escalation: Added an authErr check before the generic exit-1 throw: any batch member with exitCode: 3 (AUTH_REQUIRED / AUTH_INVALID) escalates the whole batch to exit 3 with an actionable message.
  • Idempotency Key Overflow (D4): Initial chunk dispatch now truncates the base key so base + :chunkN never exceeds 256 chars, matching the identical guard already present in the deferred-retry path.

Testing

Added 9 tests to src/commands/test.rerun.spec.ts across three describe blocks:

  • [fix-exitcode]: AUTH_REQUIRED escalates to exit 3; RATE_LIMITED and NOT_FOUND remain exit 1 (no spurious escalation)
  • [fix-auth-escalation]: auth failure exits 3; mixed pass+auth batch exits 3; non-auth failure exits 1
  • [fix-D4]: short key passes through unchanged; 249-char key fits exactly at 256; 256-char key truncated to preserve suffix

Files Changed

  • src/commands/test.ts
  • src/commands/test.rerun.spec.ts

pollAccepted in runTestRerun hardcoded exitCode:1 on ApiError, causing
the auth-escalation find(r => r.error?.exitCode === 3) to always return
undefined -- auth failures silently exited 1 instead of 3.

- preserve err.exitCode in pollAccepted (mirrors runTestRunAll fix)
- add auth escalation block before generic exit-1 throw
- bound initial chunk idempotency key to <=256 chars (mirrors retry path)
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