Skip to content

feat: [OpenAPI] GZIP encoding#1110

Merged
CharlesDuboisSAP merged 12 commits intomainfrom
gzip
Mar 13, 2026
Merged

feat: [OpenAPI] GZIP encoding#1110
CharlesDuboisSAP merged 12 commits intomainfrom
gzip

Conversation

@CharlesDuboisSAP
Copy link
Contributor

@CharlesDuboisSAP CharlesDuboisSAP commented Mar 4, 2026

Context

SAP/cloud-sdk-java-backlog#363.

Smaller payload.
Corresponding AI SDK PR:

Feature scope:

  • If Content-Encoding is set to gzip -> compress the request payload

Definition of Done

  • Functionality scope stated & covered
  • Tests cover the scope above
  • Error handling created / updated & covered by the tests above
  • Documentation updated
  • Release notes updated

@CharlesDuboisSAP CharlesDuboisSAP self-assigned this Mar 4, 2026
@CharlesDuboisSAP CharlesDuboisSAP added the please review Request to review a pull request label Mar 4, 2026
Copy link

@ZhongpinWang ZhongpinWang left a comment

Choose a reason for hiding this comment

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

Some clean code ideas. Bear my first Java PR review with some old JS habits. 😁

Comment on lines +568 to +570
"gzip".equals(headerParams.get("Content-Encoding"))
? serializeGzip(body, contentTypeObj)
: serialize(body, formParams, contentTypeObj));
Copy link

@ZhongpinWang ZhongpinWang Mar 5, 2026

Choose a reason for hiding this comment

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

[pp] Maybe this part can be extracted into a separate function and do "switch case" for different encodings? Just for better code structure since gzip is only one of the many possible values of content encoding.

}
}

private HttpEntity serializeGzip( final Object body, final ContentType contentType )

Choose a reason for hiding this comment

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

[pp/req] (req for request changes, but up to you to decide) Also the current serializeGzip() cannot handle form data?

What about using the current serialize() method first, after getting the HttpEntity, check the Content-Encoding and call HttpEntity::writeTo() to write the content to OutputStream and then compress? Makes code much cleaner IMO.

@CharlesDuboisSAP
Copy link
Contributor Author

Some clean code ideas. Bear my first Java PR review with some old JS habits. 😁

The ApiClient is straight from OpenAPI Generator. We shouldn't put any effort towards generated code or modified code from OpenAPI.

@ZhongpinWang
Copy link

The ApiClient is straight from OpenAPI Generator.

I now get your point. But aren't you then editing a generated file? How would you make serializeGzip() work with future generated version (should there be a need to regenerate from the OpenAPI generator)? Feels like one day we need to accept the fact that this file has diverged from the original one? Or just for now we put minimal effort into this. Both fine if we know the pros and cons.

Copy link
Member

@Jonas-Isr Jonas-Isr left a comment

Choose a reason for hiding this comment

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

I still feel like we should add some minimal (vibe-coded?) unit tests. I don't think the argument that this is tested through AI SDK is strong enough: If we ever discontinue the feature in AI SDK this will not be tested anymore and potentially break without us noticing.

Jonas-Isr
Jonas-Isr previously approved these changes Mar 11, 2026
Copy link
Member

@Jonas-Isr Jonas-Isr left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Member

@rpanackal rpanackal left a comment

Choose a reason for hiding this comment

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

I really like the clean approach here. Also, thanks for cleaning up the serialize method.

Copy link
Contributor

@newtork newtork left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Please consider the one exception message and give feedback on the minor case-sensitivity concern.

Copy link
Member

@rpanackal rpanackal left a comment

Choose a reason for hiding this comment

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

The case insensitive "Content-Encoding" check may need to be more robust. We can improve that later as needed

LGTM.

@CharlesDuboisSAP CharlesDuboisSAP merged commit 72f1c0c into main Mar 13, 2026
13 checks passed
@CharlesDuboisSAP CharlesDuboisSAP deleted the gzip branch March 13, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

please review Request to review a pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants