fix possible null body side outputs#1336
Merged
Merged
Conversation
204/HEAD responses produce ProcessedContent with null body bytes. Writing those to side output previously threw NPE inside GCSOutput, S3Output, or CompressedOutputWrapper, causing silent side-output data loss. Co-authored-by: Erik Schultink <eschultink@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes null-response-body handling for side-output writes across cloud storage outputs (GCS/S3) and the gzip output wrapper to avoid runtime failures when ProcessedContent.content is null.
Changes:
- Make
GCSOutputandS3Outputtreat a null body as an empty byte array when hashing and writing. - Update
CompressedOutputWrapperto compress using an empty byte array when the body is null. - Add a regression unit test ensuring
CompressedOutputWrapper.write(...)does not throw on null content.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| java/impl/gcp/src/main/java/co/worklytics/psoxy/GCSOutput.java | Null-safe hashing/writing by normalizing null body to byte[0]. |
| java/impl/aws/src/main/java/co/worklytics/psoxy/aws/S3Output.java | Null-safe hashing/writing and correct contentLength for null body. |
| java/core/src/main/java/co/worklytics/psoxy/gateway/impl/output/CompressedOutputWrapper.java | Normalize null body for compression path; adjusts gzip helper signature. |
| java/core/src/test/java/co/worklytics/psoxy/gateway/impl/output/CompressedOutputWrapperTest.java | Adds regression test for null-content write behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
35
to
+37
| try { | ||
| if (!Objects.equals(COMPRESSION_TYPE, content.getContentEncoding())) { | ||
| byte[] rawContent = content.getContent() != null ? content.getContent() : new byte[0]; | ||
| if (!Objects.equals(COMPRESSION_TYPE, content.getContentEncoding())) { |
Comment on lines
54
to
57
| byte[] gzipContent(byte[] content) throws WriteFailure { | ||
| try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); | ||
| GZIPOutputStream gzipOutputStream = new GZIPOutputStream(byteArrayOutputStream)) { | ||
| gzipOutputStream.write(content); |
aperez-worklytics
approved these changes
Jul 1, 2026
aperez-worklytics
left a comment
Contributor
There was a problem hiding this comment.
Approved to not be a blocker, but Id consider my suggestion
- Centralize null-body normalization in ProcessedContent.getContent() - Fix CompressedOutputWrapper gzip-already-encoded path for null bodies - Restore @nonnull on gzipContent; add regression test for pre-gzipped null content - Simplify GCSOutput and S3Output to use normalized getContent() Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Fixes
Change implications
CHANGELOG.mdanything that will show up interraform plan/applythat isn't obviously a no-op? No — runtime behavior fix only