fix(test): reject empty code get --out and strip code-file BOM#34
Open
SahilRakhaiya05 wants to merge 2 commits into
Open
fix(test): reject empty code get --out and strip code-file BOM#34SahilRakhaiya05 wants to merge 2 commits into
SahilRakhaiya05 wants to merge 2 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two silent-failure fixes in the test command surface:
1.
test code get --outwith empty inline codeWhen the API returns an empty/null
codebody in text mode, the CLI printed a stderr hint and exited 0 - but if--outwas 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-filePlan/steps JSON reads already strip a leading BOM from PowerShell 5.1
Set-Content -Encoding utf8files.readCodeFile()did not - the invisibleU+FEFFprefix was uploaded as part of the test source viatest code put/test create --code-file.Fix: apply existing
stripBom()inreadCodeFile().Tests
runCodeGet: empty inline code +--out? exit 5, no file left behind; stderr hint preserved without--outrunCodePut: BOM-prefixed code file uploads body without BOM