fix(java): fix OAuth staged builder ordering and long literal default#12031
Open
fix(java): fix OAuth staged builder ordering and long literal default#12031
Conversation
…ilder ordering bug Co-Authored-By: thomas@buildwithfern.com <tjb9dcshop@gmail.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: thomas@buildwithfern.com <tjb9dcshop@gmail.com>
Co-Authored-By: thomas@buildwithfern.com <tjb9dcshop@gmail.com>
Co-Authored-By: thomas@buildwithfern.com <tjb9dcshop@gmail.com>
Co-Authored-By: thomas@buildwithfern.com <tjb9dcshop@gmail.com>
Co-Authored-By: thomas@buildwithfern.com <tjb9dcshop@gmail.com>
Co-Authored-By: thomas@buildwithfern.com <tjb9dcshop@gmail.com>
Co-Authored-By: thomas@buildwithfern.com <tjb9dcshop@gmail.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.
Description
Refs: Customer reproduction case for Java SDK OAuth compilation failures
This PR fixes two bugs in the Java SDK's
OAuthTokenSuppliergenerator:Staged builder ordering bug: The generator hardcoded
clientIdandclientSecretas the first builder method calls, but the staged builder requires properties to be called in their definition order. Fixed by collecting properties from the request body in order and building the request accordingly.Long literal bug: The default
expiresInvalue used3600(int) instead of3600L(long), causing a type mismatch whenexpiresInisOptional<Long>. Now conditionally uses the correct literal suffix based on the actual type (3600Lfor Long/Uint64,3600for Integer/Uint).Changes Made
test-definitions/fern/apis/exhaustive/definition/oauth.ymlwith a token endpoint wheregrant_typeis required and comes beforeclient_idtest-definitions/fern/apis/exhaustive/definition/api.ymlto use OAuth authenticationOAuthTokenSupplierGenerator.java:buildFetchTokenMethodto collect and iterate through request body properties in definition ordercollectRequestBodyProperties()helper to gather properties from headers and bodyextractLiteral()helper to detect literal propertiesisLongType()helper to check if a type requires theLsuffix (handles Long, Uint64)RequestBodyPropertyinner class to represent properties with their metadata3600Lor3600based on the expires_in typegenerators/java/sdk/versions.ymlwith changelog for v3.34.8OAuthTokenSuppliercodeTesting
The fix can be verified by running compilation on the generated output:
Before fix - errors:
After fix - compiles successfully with correct ordering:
Human Review Checklist
propertyToFieldNamemap correctly handles all naming conventionsisLongType()usesPrimitiveTypeV1visitor - verify this covers all cases (V2 types?)isLongType()handles Optional containers but not Nullable - verify this is sufficient for OAuth use casesLink to Devin run: https://app.devin.ai/sessions/c08dddf1877142de9c8c40234b8812df
Requested by: @tjb9dc