Skip to content

fix possible null body side outputs#1336

Merged
eschultink merged 3 commits into
rc-v0.6.7from
s228-null-body-side-outputs
Jul 1, 2026
Merged

fix possible null body side outputs#1336
eschultink merged 3 commits into
rc-v0.6.7from
s228-null-body-side-outputs

Conversation

@eschultink

Copy link
Copy Markdown
Member

Fixes

  • incorrect handling of side-output writes when the response body is null, for GCS, S3, and gzip-wrapped outputs.

Change implications

  • dependencies added/changed? no
  • something important to note in future release notes?
    • NOTE in CHANGELOG.md anything that will show up in terraform plan/apply that isn't obviously a no-op? No — runtime behavior fix only
    • breaking changes? No — bug fix; no API or module contract changes expected

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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 GCSOutput and S3Output treat a null body as an empty byte array when hashing and writing.
  • Update CompressedOutputWrapper to 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 aperez-worklytics left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved to not be a blocker, but Id consider my suggestion

Comment thread java/impl/aws/src/main/java/co/worklytics/psoxy/aws/S3Output.java Outdated
Comment thread java/impl/aws/src/main/java/co/worklytics/psoxy/aws/S3Output.java Outdated
- 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>
@eschultink eschultink merged commit 18a035a into rc-v0.6.7 Jul 1, 2026
119 checks passed
@eschultink eschultink deleted the s228-null-body-side-outputs branch July 1, 2026 18:00
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.

4 participants