Skip to content

fix: expose error status, headers and body on failed clientBatchCheck items - #381

Merged
SoulPancake merged 2 commits into
mainfrom
fix/issue-380
Aug 31, 2026
Merged

fix: expose error status, headers and body on failed clientBatchCheck items#381
SoulPancake merged 2 commits into
mainfrom
fix/issue-380

Conversation

@SoulPancake

@SoulPancake SoulPancake commented Aug 29, 2026

Copy link
Copy Markdown
Member

The throwable passed to ClientBatchCheckClientResponse is the CompletionException from the check future, so the instanceof FgaError branch never matched and statusCode, headers and rawResponse stayed null, making getStatusCode() throw NullPointerException. Unwrap the wrapper exception before the check.

Fixes #380

Description

What problem is being solved?

How is it being solved?

What changes are made to solve it?

References

Review Checklist

  • I have clicked on "allow edits by maintainers".
  • I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
  • The correct base branch is being used, if not main
  • I have added tests to validate that the change in functionality is working as expected

Summary by CodeRabbit

  • Bug Fixes

    • Improved batch check error handling by correctly unwrapping underlying exceptions.
    • Preserved HTTP status codes, response bodies, and headers when available, including cases without an HTTP response.
  • Tests

    • Expanded error-handling coverage for batch checks returning 400, 404, and 500 responses.

… items

The throwable passed to ClientBatchCheckClientResponse is the
CompletionException from the check future, so the instanceof FgaError
branch never matched and statusCode, headers and rawResponse stayed
null, making getStatusCode() throw NullPointerException. Unwrap the
wrapper exception before the check.

Fixes #380
@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 44036503-2270-4947-b345-5725e270af53

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f6c7a746-4a56-458d-8ae5-3e7e8ef4a6c1

📥 Commits

Reviewing files that changed from the base of the PR and between 37317f2 and a53c11f.

📒 Files selected for processing (2)
  • src/main/java/dev/openfga/sdk/api/client/model/ClientBatchCheckClientResponse.java
  • src/test/java/dev/openfga/sdk/api/client/OpenFgaClientTest.java

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


Walkthrough

The batch-check response constructor now unwraps asynchronous exceptions and safely copies error response metadata. Tests verify status codes, raw bodies, and headers for 400, 404, and 500 errors.

Changes

Batch check error metadata

Layer / File(s) Summary
Unwrap errors and validate response metadata
src/main/java/dev/openfga/sdk/api/client/model/ClientBatchCheckClientResponse.java, src/test/java/dev/openfga/sdk/api/client/OpenFgaClientTest.java
The constructor unwraps CompletionException and ExecutionException, handles null response headers, and preserves error metadata. Tests validate status codes, raw response bodies, and headers for failed checks.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to a53c1

Failed batch-check items now expose the existing error status, headers, and body instead of leaving them unavailable. No actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: aaguiarz

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: exposing error status, headers, and body for failed clientBatchCheck items.
Linked Issues check ✅ Passed The implementation addresses issue #380 by unwrapping CompletionException and ExecutionException, copying FgaError response metadata, and adding tests for status code, headers, and raw response body a…
Out of Scope Changes check ✅ Passed All changes are related to issue #380. The production fix and supporting clientBatchCheck tests remain within scope.
Full details: Linked Issues check

Explanation

The implementation addresses issue #380 by unwrapping CompletionException and ExecutionException, copying FgaError response metadata, and adding tests for status code, headers, and raw response body across 400, 404, and 500 errors.

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-380

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 Aug 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.86%. Comparing base (37317f2) to head (661ebee).

Files with missing lines Patch % Lines
...i/client/model/ClientBatchCheckClientResponse.java 71.42% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #381      +/-   ##
============================================
+ Coverage     38.73%   38.86%   +0.13%     
- Complexity     1292     1298       +6     
============================================
  Files           198      198              
  Lines          7707     7711       +4     
  Branches        900      902       +2     
============================================
+ Hits           2985     2997      +12     
+ Misses         4576     4567       -9     
- Partials        146      147       +1     

☔ 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.

Pull request overview

Fixes failed batch-check items so HTTP error metadata is exposed correctly.

Changes:

  • Unwraps asynchronous exception wrappers before detecting FgaError.
  • Safely extracts status, headers, and raw response.
  • Adds coverage for HTTP 400, 404, and 500 failures.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
ClientBatchCheckClientResponse.java Extracts metadata from wrapped errors.
OpenFgaClientTest.java Verifies failed-item HTTP metadata.

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

@SoulPancake
SoulPancake marked this pull request as ready for review August 31, 2026 05:12
@SoulPancake
SoulPancake requested a review from a team as a code owner August 31, 2026 05:12
Network failures (connection refused, timeout, DNS) exhaust retries and
fail with a plain ApiException rather than an FgaError, so statusCode
stays null and the primitive getStatusCode() threw the same
NullPointerException as issue #380. Return a boxed, null-documented
Integer instead of a fake sentinel status, document the null behaviour
of getHeaders() and getRawResponse(), and cover the exhausted-retries
network-failure path with a WireMock connection-fault test.
@SoulPancake
SoulPancake requested a review from a team August 31, 2026 12:32
@Siddhant-K-code

Copy link
Copy Markdown
Member

getStatusCode() now returns Integer instead of int. This is source-compatible, but it changes the JVM method descriptor and is binary-incompatible for precompiled consumers. Non-blocking, but worth calling out in the changelog or release notes.

@SoulPancake
SoulPancake added this pull request to the merge queue Aug 31, 2026
@Siddhant-K-code

Copy link
Copy Markdown
Member

@SoulPancake - do you think, we should update in changelog?

@SoulPancake

Copy link
Copy Markdown
Member Author

@Siddhant-K-code
That can be done while we are creating the release as changelog is auto-generated from commits during the release-please PR creation

Merged via the queue into main with commit 8da296e Aug 31, 2026
27 checks passed
@SoulPancake
SoulPancake deleted the fix/issue-380 branch August 31, 2026 15:21
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.

ClientBatchCheckClientResponse.getStatusCode() throws NullPointerException for failed checks

4 participants