fix(CLI): restore empty-file download when a tag filter matches nothing - #1235
Merged
Conversation
…ring PR #1085 made copyToDestination fail when the API returns an empty body, which happens whenever a filter (e.g. --tags) matches zero translations. That's a valid empty export, not a failed download, so treat it as one: write an empty file instead of erroring. Also fix the cache write ordering in downloadSynchronously and PullParallel: the ETag/Last-Modified was being persisted before copyToDestination ran, so a failed write could still poison the cache into reporting 304 Not Modified for a locale that was never written. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
API changelog (oasdiff)Doc-only edits (descriptions, examples) do not appear here. |
Redirect the openapi-generator/npm output from the generate step to a log file that's only dumped on failure, and switch rspec to the documentation formatter so CI logs show test names instead of dots.
Sven Dunemann (forelabs)
approved these changes
Aug 24, 2026
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
A client reported that PR #1085 broke
phrase pullwhen a--tagsfilter matches zero translations: previously the CLI silently wrote an empty locale file in that case; after #1085 it fails withno content to write to ....Root cause: the Phrase API returns
200 OKwith an empty body when a filter matches nothing. The SDK'sdecode()leaves the*os.Filereturn valuenilin that case with no error. #1085'scopyToDestinationwas hardened (as an "address expert review findings" cleanup, not in response to this specific case) to treat a nil file as a hard error — which is exactly the empty-export case, not a swallowed failure.copyToDestination: treat a nil file as a valid empty export again, writing an empty file, with a comment explaining why nil isn't an error here.downloadSynchronously/PullParallel: the download cache (ETag/Last-Modified) was being persisted beforecopyToDestinationran, so a failed write could still get cached as if it succeeded, causing subsequent runs to report304 Not Modifiedfor a locale that was never actually written to disk.Test plan
cmd/internal/pull_parallel_test.go) covering: nil file writes an empty file, nil file truncates a previously-populated file (documents the accepted tradeoff), and a real file still copies content correctly.spec/pull_spec.rb) that mocks the download endpoint returning200with an empty body for a--tagsfilter, in both sync and--parallelmodes, assertingphrase pullexits0and writes an empty file.no content to write to ...).phrase-goversion and run the full Go + Ruby suites (this environment has an unrelated, pre-existingphrase-goversion mismatch that prevented a full local build).🤖 Generated with Claude Code