Skip to content

Conversation

@aaguiarz
Copy link
Member

@aaguiarz aaguiarz commented Mar 1, 2023

No description provided.

@aaguiarz aaguiarz requested a review from a team as a code owner March 1, 2023 20:47
@rhamzeh rhamzeh merged commit 21f5dda into main Mar 3, 2023
@rhamzeh rhamzeh deleted the aaguiarz-fossa-1 branch March 3, 2023 12:52
This was referenced Mar 3, 2023
curfew-marathon added a commit that referenced this pull request Jul 31, 2025
…nsaction writes

Addresses GitHub issue #99 by implementing proper error handling for non-transaction
writes to match JavaScript and .NET SDK behavior.

### Key Changes:

**New Model Classes:**
- Add ClientWriteStatus enum with SUCCESS/FAILURE values
- Add ClientWriteSingleResponse class for individual tuple write results
- Extend ClientWriteResponse with new constructor supporting detailed results

**Core Logic Updates:**
- Completely rewrite writeNonTransaction method with parallel processing
- Implement individual error isolation per chunk using CompletableFuture.allOf()
- Add authentication error re-throwing to maintain existing behavior
- Process writes and deletes in parallel chunks for improved performance

**Error Handling Improvements:**
- Individual tuple failures no longer stop entire operation
- Each tuple gets SUCCESS/FAILURE status with optional error details
- Authentication errors (FgaApiAuthenticationError) are properly re-thrown
- Non-authentication errors are captured per tuple without stopping others

**Test Coverage:**
- Add comprehensive unit tests for new model classes
- Update OpenFgaClientTest with mixed success/failure scenarios
- Test authentication error handling and individual tuple status tracking

**Configuration Updates:**
- Register new template files in config.overrides.json
- Maintain backward compatibility with existing API signatures

### Technical Details:

The implementation uses CompletableFuture.allOf() for parallel chunk processing,
with .exceptionally() handlers that distinguish between authentication errors
(which should halt execution) and other errors (which should be captured per tuple).

Empty chunk handling is properly implemented to avoid null pointer exceptions,
and the chunksOf utility method handles edge cases correctly.

### Backward Compatibility:

All existing API signatures are preserved. The new detailed response format
is available through the new ClientWriteResponse constructor while maintaining
the legacy ApiResponse-based constructor for transaction-based writes.

Resolves: openfga/java-sdk#99
curfew-marathon added a commit that referenced this pull request Aug 4, 2025
…l writes

- Update writeNonTransaction method to properly isolate chunk failures
- Failed chunks now mark tuples as FAILURE while allowing other chunks to continue processing
- Authentication errors are re-thrown to stop all processing as expected
- Matches .NET SDK behavior where 'some will pass some will fail' for non-transactional operations
- Each chunk processes independently with proper error boundary isolation
- Resolves issue #99 for Java SDK non-transaction write error handling

This ensures that individual chunk failures don't affect the processing of other chunks,
allowing for proper partial success scenarios in non-transactional write operations.
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