Skip to content

feat!: migrate json serialization to jackson 3 - #392

Open
Adrastopoulos wants to merge 3 commits into
openfga:mainfrom
Adrastopoulos:gabriel/jackson3
Open

Adrastopoulos wants to merge 3 commits into
openfga:mainfrom
Adrastopoulos:gabriel/jackson3

Conversation

@Adrastopoulos

@Adrastopoulos Adrastopoulos commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Description

Moves the SDK to Jackson 3 after the serialization bridge. Request, response, error and streaming JSON handling stay behind the SDK-owned API.

What problem is being solved?

The bridge still uses Jackson 2. The next major needs to switch the implementation without putting Jackson types back into the public API.

How is it being solved?

Jackson3JsonSerializer uses the existing mapper configuration on Jackson 3. The deprecated mapper and TypeReference APIs are removed; callers use JsonSerializer and SdkTypeToken instead.

This is for the next major. The Jackson 2 bridge must ship before this lands. Release versions are unchanged.

What changes are made to solve it?

  • Use Jackson 3 for default serialization and preserve byte-for-byte wire output.
  • Remove the deprecated mapper and type-reference APIs, including the streaming compatibility fields.
  • Keep core and databind as runtime dependencies and annotations as an API dependency.
  • Remove the unused nullable dependency and use built-in Java time support.
  • Update tests, examples, and migration notes.
  • Document the serializer error contract and test malformed byte/text input, concrete byte responses, and getter failures.

References

Test plan

  • ./gradlew build: 566 unit tests passed. Jackson3JsonSerializer has 26/26 lines and 7/7 methods covered.
  • ./gradlew test-integration: 60 passed, one existing skip. Used the local Colima socket.
  • Clean Java SDK regeneration matched all generated files after formatting.
  • Live OpenFGA smoke run covered store/model creation, write, read, check, list, streaming, deletion, and server error decoding. Jackson 2 databind was absent.
  • A consumer compiled without Jackson core or databind on its compile classpath. The generated POM keeps both at runtime scope.
  • The three changed example projects compiled against the local SDK. This included Java and Kotlin. The basic example used a Java 17 target to match its Kotlin target.
  • Vale found no new errors or warnings on changed prose. Existing findings remain elsewhere in the files.

Check status

Local Snyk scans found no vulnerable paths in the SDK production runtime. The root broad scans found identical advisories and dependency paths on the base and PR.

The two DSL examples retain a Jackson 2 BOM for openfga-language alongside Jackson 3. Their OpenTelemetry BOM now matches the SDK. Each example dropped from 16 Snyk findings to three existing ANTLR findings, for which Snyk lists no fix.

Both examples built and ran against OpenFGA. The executor example streamed 200 objects with each overload; the streaming example returned 2,000 objects. The hosted Snyk report remains inaccessible, so these results do not establish its exact failure cause.

Review Checklist

  • Allow edits by maintainers is enabled.
  • Migration notes cover the changed API.
  • The correct base branch is used.
  • Tests cover serialization compatibility and wire parity.
  • Generated-file changes have matching source-template changes.

Summary by CodeRabbit

  • Changed

    • Upgraded the SDK’s default JSON serialization to Jackson 3 while preserving Jackson-compatible serialization behavior.
    • Applications can now provide custom JSON serialization through the SDK’s serializer interface.
    • Streaming response type configuration uses SdkTypeToken instead of Jackson TypeReference.
    • Examples and integration guidance now demonstrate Jackson 3 configuration.
  • Migration

    • Existing applications using removed Jackson 2 mapper APIs or TypeReference integrations must migrate to the serializer and type-token APIs described in the updated documentation.

@coderabbitai

coderabbitai Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 78f19e89-41e3-45a4-a2db-4b94dded1cd0

📥 Commits

Reviewing files that changed from the base of the PR and between 209bd3d and 0a58c2e.

📒 Files selected for processing (34)
  • CHANGELOG.md
  • build.gradle
  • docs/ApiExecutor.md
  • examples/api-executor/build.gradle
  • examples/api-executor/src/main/java/dev/openfga/sdk/example/ApiExecutorExample.java
  • examples/api-executor/src/main/java/dev/openfga/sdk/example/StreamingApiExecutorExample.java
  • examples/basic-examples/build.gradle
  • examples/basic-examples/src/main/java/dev/openfga/sdk/example/Example1.java
  • examples/basic-examples/src/main/kotlin/dev/openfga/sdk/example/KotlinExample1.kt
  • examples/streamed-list-objects/build.gradle
  • examples/streamed-list-objects/src/main/java/dev/openfga/sdk/example/StreamedListObjectsExample.java
  • src/main/java/dev/openfga/sdk/api/BaseStreamingApi.java
  • src/main/java/dev/openfga/sdk/api/client/ApiClient.java
  • src/main/java/dev/openfga/sdk/api/client/Jackson2JsonSerializer.java
  • src/main/java/dev/openfga/sdk/api/client/Jackson3JsonSerializer.java
  • src/main/java/dev/openfga/sdk/api/client/JsonSerializer.java
  • src/main/java/dev/openfga/sdk/api/client/OpenFgaClient.java
  • src/main/java/dev/openfga/sdk/api/client/StreamingApiExecutor.java
  • src/test-integration/java/dev/openfga/sdk/api/OpenFgaApiIntegrationTest.java
  • src/test-integration/java/dev/openfga/sdk/api/client/ApiExecutorIntegrationTest.java
  • src/test-integration/java/dev/openfga/sdk/api/client/OpenFgaClientIntegrationTest.java
  • src/test-integration/java/dev/openfga/sdk/errors/FgaErrorIntegrationTest.java
  • src/test-integration/java/dev/openfga/sdk/example/Example1.java
  • src/test/java/dev/openfga/sdk/LegacyStreamingApiTest.java
  • src/test/java/dev/openfga/sdk/TestJsonSerializer.java
  • src/test/java/dev/openfga/sdk/api/OpenFgaApiTest.java
  • src/test/java/dev/openfga/sdk/api/StreamingApiTest.java
  • src/test/java/dev/openfga/sdk/api/auth/OAuth2ClientTest.java
  • src/test/java/dev/openfga/sdk/api/client/ApiClientTest.java
  • src/test/java/dev/openfga/sdk/api/client/Jackson3JsonSerializerTest.java
  • src/test/java/dev/openfga/sdk/api/client/OpenFgaClientHeadersTest.java
  • src/test/java/dev/openfga/sdk/api/client/OpenFgaClientTest.java
  • src/test/java/dev/openfga/sdk/api/client/StreamedListObjectsTest.java
  • src/test/java/dev/openfga/sdk/api/client/StreamingApiExecutorTest.java
💤 Files with no reviewable changes (5)
  • src/main/java/dev/openfga/sdk/api/client/StreamingApiExecutor.java
  • src/main/java/dev/openfga/sdk/api/client/OpenFgaClient.java
  • src/main/java/dev/openfga/sdk/api/client/Jackson2JsonSerializer.java
  • src/test/java/dev/openfga/sdk/LegacyStreamingApiTest.java
  • src/main/java/dev/openfga/sdk/api/BaseStreamingApi.java

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

The SDK migrates JSON serialization from Jackson 2 to Jackson 3. It removes deprecated ObjectMapper and TypeReference APIs, adds Jackson3JsonSerializer, updates dependencies, and migrates documentation, examples, integration tests, and unit tests.

Changes

Jackson 3 migration

Layer / File(s) Summary
Serializer implementation and API removal
src/main/java/dev/openfga/sdk/api/...
JsonSerializer.createDefault() now uses Jackson3JsonSerializer. Deprecated Jackson 2 serializer, ObjectMapper APIs, and TypeReference streaming APIs were removed.
Dependency and migration contract updates
build.gradle, CHANGELOG.md, docs/ApiExecutor.md
Build dependencies use Jackson 3 coordinates. Documentation describes SdkTypeToken, JsonSerializer, and application dependency changes.
Example application migration
examples/...
Examples use Jackson 3 JsonMapper instances and SdkTypeToken for generic streaming responses.
Integration test migration
src/test-integration/...
Integration tests use Jackson 3 imports, mapper construction, and exception types.
Unit test serializer and client updates
src/test/...
Unit tests use JsonSerializer implementations and validate serialization compatibility, generic deserialization, customization, and error handling.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant Application
  participant OpenFgaClient
  participant ApiClient
  participant JsonSerializer
  Application->>OpenFgaClient: request streamingApiExecutor(SdkTypeToken)
  OpenFgaClient->>ApiClient: execute request
  ApiClient->>JsonSerializer: deserialize response
  JsonSerializer-->>OpenFgaClient: typed StreamResult
  OpenFgaClient-->>Application: streaming response
Loading

Suggested reviewers: soulpancake

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 60 functions across 23 files. (6 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: migrating JSON serialization to Jackson 3. The breaking-change marker is appropriate because deprecated Jackson 2 and TypeReference APIs were…
Full details: Docstring Coverage

Explanation

Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 60 functions across 23 files. (6 skipped: 6 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov-commenter

codecov-commenter commented Sep 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 39.33%. Comparing base (209bd3d) to head (c645900).

❌ Your project status has failed because the head coverage (39.33%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #392      +/-   ##
============================================
- Coverage     39.34%   39.33%   -0.01%     
+ Complexity     1336     1330       -6     
============================================
  Files           202      202              
  Lines          7791     7757      -34     
  Branches        912      912              
============================================
- Hits           3065     3051      -14     
+ Misses         4579     4549      -30     
- Partials        147      157      +10     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Copilot review overview

🟡 Changes recommended

Remaining README examples reference removed Jackson 2 APIs and no longer compile with the new dependency scopes.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

Migrates the SDK’s internal JSON serialization from Jackson 2 to Jackson 3 while keeping public serialization library-neutral.

Changes:

  • Adds the Jackson 3 serializer and preserves wire compatibility.
  • Removes deprecated Jackson 2 mapper and TypeReference APIs.
  • Updates dependencies, tests, examples, and migration documentation.
File Description
src/​test/​java/​dev/​openfga/​sdk/​TestJsonSerializer.java Adds a Jackson 3 test serializer.
src/​test/​java/​dev/​openfga/​sdk/​LegacyStreamingApiTest.java Removes legacy Jackson 2 streaming tests.
src/​test/​java/​dev/​openfga/​sdk/​api/​StreamingApiTest.java Tests streaming through SDK serialization APIs.
src/​test/​java/​dev/​openfga/​sdk/​api/​OpenFgaApiTest.java Uses the test serializer.
src/​test/​java/​dev/​openfga/​sdk/​api/​client/​StreamingApiExecutorTest.java Removes TypeReference compatibility coverage.
src/​test/​java/​dev/​openfga/​sdk/​api/​client/​StreamedListObjectsTest.java Uses the default serializer.
src/​test/​java/​dev/​openfga/​sdk/​api/​client/​OpenFgaClientTest.java Replaces mapper-based client construction.
src/​test/​java/​dev/​openfga/​sdk/​api/​client/​OpenFgaClientHeadersTest.java Uses the test serializer.
src/​test/​java/​dev/​openfga/​sdk/​api/​client/​Jackson3JsonSerializerTest.java Covers Jackson 3 compatibility and failures.
src/​test/​java/​dev/​openfga/​sdk/​api/​client/​Jackson2JsonSerializerTest.java Removes Jackson 2 serializer tests.
src/​test/​java/​dev/​openfga/​sdk/​api/​client/​ApiClientTest.java Tests custom serializer configuration.
src/​test/​java/​dev/​openfga/​sdk/​api/​auth/​OAuth2ClientTest.java Uses the default serializer.
src/​test-integration/​java/​dev/​openfga/​sdk/​example/​Example1.java Migrates integration parsing to Jackson 3.
src/​test-integration/​java/​dev/​openfga/​sdk/​errors/​FgaErrorIntegrationTest.java Migrates error tests to Jackson 3.
src/​test-integration/​java/​dev/​openfga/​sdk/​api/​OpenFgaApiIntegrationTest.java Migrates mapper and exception APIs.
src/​test-integration/​java/​dev/​openfga/​sdk/​api/​client/​OpenFgaClientIntegrationTest.java Migrates client integration parsing.
src/​test-integration/​java/​dev/​openfga/​sdk/​api/​client/​ApiExecutorIntegrationTest.java Migrates executor integration parsing.
src/​main/​java/​dev/​openfga/​sdk/​api/​client/​StreamingApiExecutor.java Removes the Jackson TypeReference constructor.
src/​main/​java/​dev/​openfga/​sdk/​api/​client/​OpenFgaClient.java Removes the TypeReference overload.
src/​main/​java/​dev/​openfga/​sdk/​api/​client/​JsonSerializer.java Selects Jackson 3 and documents its contract.
src/​main/​java/​dev/​openfga/​sdk/​api/​client/​Jackson3JsonSerializer.java Implements default Jackson 3 serialization.
src/​main/​java/​dev/​openfga/​sdk/​api/​client/​Jackson2JsonSerializer.java Removes the Jackson 2 implementation.
src/​main/​java/​dev/​openfga/​sdk/​api/​client/​ApiClient.java Removes deprecated mapper APIs.
src/​main/​java/​dev/​openfga/​sdk/​api/​BaseStreamingApi.java Removes Jackson compatibility fields and constructors.
examples/​streamed-list-objects/​src/​main/​java/​dev/​openfga/​sdk/​example/​StreamedListObjectsExample.java Migrates example parsing to Jackson 3.
examples/​streamed-list-objects/​build.gradle Updates example dependencies.
examples/​basic-examples/​src/​main/​kotlin/​dev/​openfga/​sdk/​example/​KotlinExample1.kt Migrates Kotlin parsing to Jackson 3.
examples/​basic-examples/​src/​main/​java/​dev/​openfga/​sdk/​example/​Example1.java Migrates Java parsing to Jackson 3.
examples/​basic-examples/​build.gradle Updates basic example dependencies.
examples/​api-executor/​src/​main/​java/​dev/​openfga/​sdk/​example/​StreamingApiExecutorExample.java Replaces TypeReference with SdkTypeToken.
examples/​api-executor/​src/​main/​java/​dev/​openfga/​sdk/​example/​ApiExecutorExample.java Applies formatting cleanup.
examples/​api-executor/​build.gradle Updates executor example dependencies.
docs/​ApiExecutor.md Documents SdkTypeToken streaming.
CHANGELOG.md Adds migration guidance.
build.gradle Moves production dependencies to Jackson 3.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docs/ApiExecutor.md
```java
// Hypothetical endpoint whose response wraps a generic Page<Item>
TypeReference<StreamResult<Page<Item>>> typeRef = new TypeReference<StreamResult<Page<Item>>>() {};
SdkTypeToken<StreamResult<Page<Item>>> type = new SdkTypeToken<StreamResult<Page<Item>>>() {};
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.

3 participants