chore: reverse sync java sdk#706
Conversation
WalkthroughThis PR updates the Java SDK generator configuration and templates with version bump to 0.9.9, centralizes OAuth2 authentication handling, introduces new feature flags, adds ApiExecutor documentation, and updates minimum Java version requirement to Java 17. ChangesJava SDK OAuth2 Refactoring and Configuration Updates
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR updates the OpenFGA SDK Generator’s templates/config for the Java SDK to reflect recent Java SDK changes, including documentation updates and refactoring how auth headers are applied in generated HTTP requests.
Changes:
- Update Java client generation config (including a Java package version bump and README templating flags).
- Refactor Java native client templates to centralize applying auth headers (including streaming requests).
- Expand Java README content (installation, OAuth2 guidance, retries, and “calling other endpoints”).
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| config/common/files/README.mustache | Adds a conditional TOC entry for “Client Batch Check” and conditionally includes “Calling Other Endpoints” in the TOC. |
| config/clients/java/template/src/main/constants/FgaConstants.mustache | Updates Java SDK USER_AGENT constant formatting. |
| config/clients/java/template/README_retries.mustache | Adds “Calling Other Endpoints” documentation and streaming executor example. |
| config/clients/java/template/README_installation.mustache | Updates documented minimum Java version and adds release-please version markers around dependency snippets. |
| config/clients/java/template/README_initializing.mustache | Improves OAuth2 client credentials documentation and clarifies apiTokenIssuer usage. |
| config/clients/java/template/README_custom_badges.mustache | Updates the Socket badge URL to incorporate release-please version templating. |
| config/clients/java/template/README_calling_api.mustache | Fixes typos/errors in the Client Batch Check example snippet. |
| config/clients/java/template/libraries/native/BaseStreamingApi.mustache | Ensures streaming requests apply auth headers via ApiClient.applyAuthHeader. |
| config/clients/java/template/libraries/native/ApiClient.mustache | Introduces centralized applyAuthHeader with OAuth2 client caching; modifies default base URI behavior. |
| config/clients/java/template/libraries/native/api.mustache | Switches generated API calls to use ApiClient.applyAuthHeader and passes telemetry into request attempts. |
| config/clients/java/config.overrides.json | Bumps Java SDK version and enables README templating flags (supportsCallingOtherEndpoints, hideClientBatchCheckToc). |
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
config/clients/java/template/README_calling_api.mustache (1)
451-467:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winFix Java “Batch Check” docs sample to use consistent item type and keep fluent chaining intact
In
config/clients/java/template/README_calling_api.mustache(Batch Check example,checks(List.of(...))), the list mixesnew ClientBatchCheckItem()withnew ClientCheckRequest(), and one entry has a comma immediately after._object(...), breaking the fluent chain so.correlationId(...)/.contextualTuples(...)are no longer attached to the same request item.
- Use
new ClientBatchCheckItem()for every element in thechecks(List.of(...))list.- Move the comma so it terminates the full item expression (after the last chained call), not right after
._object(...).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@config/clients/java/template/README_calling_api.mustache` around lines 451 - 467, The Batch Check sample uses inconsistent types and breaks fluent chaining: replace any occurrences of new ClientCheckRequest() inside the checks(List.of(...)) with new ClientBatchCheckItem() so all list entries are the same type, and ensure commas come after the full chained expression (e.g., place the comma after the final .correlationId(...) or .contextualTuples(...) call, not immediately after ._object(...)) so ._object(...), .correlationId(...), and .contextualTuples(...) remain chained on the same ClientBatchCheckItem instance.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@config/clients/java/config.overrides.json`:
- Line 6: The Java language override is missing the required FOSSA compliance
notice ID next to the existing "packageVersion": "0.9.9"; add the canonical
notice ID field used by our configs (e.g., "fossaNoticeId" or the
project-standard "noticeId") with the correct FOSSA ID string in that JSON
object for the Java override, ensure the JSON stays valid (commas/quoting) and
commit the change so compliance metadata is restored.
In `@config/clients/java/template/libraries/native/api.mustache`:
- Around line 73-83: The constructors of OpenFgaApi currently only validate
telemetry, letting null configuration or apiClient surface later; update both
constructors to fail fast by validating configuration and apiClient for null
(throw IllegalArgumentException) before creating or assigning telemetry. In the
two-arg constructor (OpenFgaApi(Configuration configuration, ApiClient
apiClient)) check configuration and apiClient for null before calling new
Telemetry(configuration) and then delegate to the three-arg constructor; in the
three-arg constructor (OpenFgaApi(Configuration configuration, ApiClient
apiClient, Telemetry telemetry)) validate all three parameters (configuration,
apiClient, telemetry) up front and assign fields only after validation.
In `@config/clients/java/template/libraries/native/ApiClient.mustache`:
- Around line 361-398: The applyAuthHeader method reads nested auth fields
without validating configuration/credentials and may NPE when
credentials.getApiToken() is null; validate the incoming Configuration and its
Credentials (and for API_TOKEN also ensure credentials.getApiToken() and its
token are non-null and throw the declared FgaInvalidParameterException with a
clear message) before accessing nested getters (reference: applyAuthHeader,
Configuration, Credentials, CredentialsMethod, API_TOKEN,
FgaInvalidParameterException); update the API_TOKEN branch to check for null
apiToken/token and throw FgaInvalidParameterException instead of letting a
NullPointerException surface.
- Around line 186-188: Harden applyAuthHeader by null-checking nested credential
fields before dereferencing: verify configuration != null,
configuration.getCredentials() != null, credentials.getApiToken() != null and
credentials.getApiToken().getToken() != null (and similarly when calling
ensureOAuth2Client that configuration.getCredentials().getClientCredentials() is
present) and throw the documented FgaInvalidParameterException with a clear
message when any required piece is missing instead of letting a
NullPointerException propagate; also audit getDefaultBaseUri/getApiUrl usage:
ensure Configuration.getApiUrl() has a safe non-localhost default or make
getDefaultBaseUri() the single source of truth and use it when building request
URIs (replace direct URI.create(configuration.getApiUrl() + path) with a call
that falls back to getDefaultBaseUri() if configuration.getApiUrl() is
null/empty) so requests never implicitly default to "http://localhost".
In `@config/clients/java/template/README_retries.mustache`:
- Around line 93-95: The example uses an undefined variable storeId when calling
ApiExecutorRequestBuilder.builder; fix by declaring a local String storeId (or
reuse the literal used earlier) before building the request so the snippet is
copy-paste runnable. Locate the ApiExecutorRequestBuilder usage and add a short
declaration (e.g., String storeId = "...";) immediately before the request
construction so .pathParam("store_id", storeId) has a defined value.
---
Outside diff comments:
In `@config/clients/java/template/README_calling_api.mustache`:
- Around line 451-467: The Batch Check sample uses inconsistent types and breaks
fluent chaining: replace any occurrences of new ClientCheckRequest() inside the
checks(List.of(...)) with new ClientBatchCheckItem() so all list entries are the
same type, and ensure commas come after the full chained expression (e.g., place
the comma after the final .correlationId(...) or .contextualTuples(...) call,
not immediately after ._object(...)) so ._object(...), .correlationId(...), and
.contextualTuples(...) remain chained on the same ClientBatchCheckItem instance.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 22b68c7f-50f3-4c72-b473-5bfddd32b6ab
📒 Files selected for processing (11)
config/clients/java/config.overrides.jsonconfig/clients/java/template/README_calling_api.mustacheconfig/clients/java/template/README_custom_badges.mustacheconfig/clients/java/template/README_initializing.mustacheconfig/clients/java/template/README_installation.mustacheconfig/clients/java/template/README_retries.mustacheconfig/clients/java/template/libraries/native/ApiClient.mustacheconfig/clients/java/template/libraries/native/BaseStreamingApi.mustacheconfig/clients/java/template/libraries/native/api.mustacheconfig/clients/java/template/src/main/constants/FgaConstants.mustacheconfig/common/files/README.mustache
Description
synchs java sdk back to the generator.
The failing build+test command in CI also passes for java with this.
Generated PR : openfga/java-sdk#348
What problem is being solved?
How is it being solved?
What changes are made to solve it?
References
Review Checklist
mainSummary by CodeRabbit
New Features
Bug Fixes
Documentation