Skip to content

fix(test): validate failure get --out before API fetch#26

Open
SahilRakhaiya05 wants to merge 1 commit into
TestSprite:mainfrom
SahilRakhaiya05:fix/failure-get-out-preflight
Open

fix(test): validate failure get --out before API fetch#26
SahilRakhaiya05 wants to merge 1 commit into
TestSprite:mainfrom
SahilRakhaiya05:fix/failure-get-out-preflight

Conversation

@SahilRakhaiya05

Copy link
Copy Markdown

Summary

runFailureGet() had a comment claiming --out is validated before the network call, but it only assigned opts.out and immediately fetched GET /tests/{id}/failure. Invalid paths (empty --out, missing parent directory, etc.) wasted an API call before failing with exit 5.

runArtifactGet() and runCodeGet() already fast-fail on bad --out paths first; this aligns failure get.

The Fix

When --out is provided:

  1. resolveBundleDir(opts.out) - rejects empty paths
  2. assertOutDirParentExists(resolvedDir) - rejects missing parents / file targets
  3. Only then issue the API fetch and writeBundle

Testing

  • Added 2 regression tests in src/commands/test.test.ts (zero fetch calls on invalid --out)
  • npx vitest run src/commands/test.test.ts -t runFailureGet - 15 passed
  • npm run typecheck and npm run lint - pass

Files changed:

  • src/commands/test.ts
  • src/commands/test.test.ts

runFailureGet now resolves and validates --out via resolveBundleDir and assertOutDirParentExists before calling GET /tests/{id}/failure, matching runArtifactGet and runCodeGet fast-fail behavior.

Adds regression tests asserting zero fetch calls on empty --out and missing parent dir paths.
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