Skip to content

fix(test): reject empty code get --out and strip code-file BOM#34

Open
SahilRakhaiya05 wants to merge 2 commits into
TestSprite:mainfrom
SahilRakhaiya05:fix/code-get-empty-out-and-code-file-bom
Open

fix(test): reject empty code get --out and strip code-file BOM#34
SahilRakhaiya05 wants to merge 2 commits into
TestSprite:mainfrom
SahilRakhaiya05:fix/code-get-empty-out-and-code-file-bom

Conversation

@SahilRakhaiya05

@SahilRakhaiya05 SahilRakhaiya05 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Two silent-failure fixes in the test command surface:

1. test code get --out with empty inline code

When the API returns an empty/null code body in text mode, the CLI printed a stderr hint and exited 0 - but if --out was set, closeOutputFile() still ran and left a zero-byte file. Agents and scripts checking file existence/size treated that as a successful download.

Fix: abort the file sink, unlink any artifact, and throw VALIDATION_ERROR (exit 5). Stderr-only text mode (no --out) behavior is unchanged.

2. UTF-8 BOM on --code-file

Plan/steps JSON reads already strip a leading BOM from PowerShell 5.1 Set-Content -Encoding utf8 files. readCodeFile() did not - the invisible U+FEFF prefix was uploaded as part of the test source via test code put / test create --code-file.

Fix: apply existing stripBom() in readCodeFile().

Tests

  • runCodeGet: empty inline code + --out ? exit 5, no file left behind; stderr hint preserved without --out
  • runCodePut: BOM-prefixed code file uploads body without BOM

When test code get --out receives an empty inline body, closeOutputFile left a zero-byte file with exit 0 — scripts and agents treated that as a successful download. Abort the sink, unlink any artifact, and surface VALIDATION_ERROR instead.

Plan/steps JSON already strip a leading UTF-8 BOM from PowerShell 5.1 files; apply the same strip to --code-file reads so uploaded test source is not corrupted by an invisible U+FEFF prefix.
Resolve conflicts in test.ts / test.test.ts by combining upstream's
atomic temp-file --out writes with this branch's empty-code rejection
(VALIDATION_ERROR exit 5) and BOM stripping. Update the pre-existing-file
empty-code regression to expect exit 5 while still asserting the file
is untouched.
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