Skip to content

Commit 9cafaa5

Browse files
authored
chore: fix readme section for error handling and contributing guide (#249)
* chore: fix readme section for error handling and contributing guide * fix: address copilot comment
1 parent 1c16fe6 commit 9cafaa5

File tree

3 files changed

+30
-24
lines changed

3 files changed

+30
-24
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Reading and following these guidelines will help us make the contribution proces
1010
* [Getting Started](#getting-started)
1111
* [Making Changes](#making-changes)
1212
* [Opening Issues](#opening-issues)
13-
* [Submitting Pull Requests](#submitting-pull-requests) [Note: We are not accepting Pull Requests at this time!]
13+
* [Submitting Pull Requests](#submitting-pull-requests)
1414
* [Getting in Touch](#getting-in-touch)
1515
* [Have a question or problem?](#have-a-question-or-problem)
1616
* [Vulnerability Reporting](#vulnerability-reporting)

README.md

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ This is an autogenerated python SDK for OpenFGA. It provides a wrapper around th
3838
- [Relationship Queries](#relationship-queries)
3939
- [Check](#check)
4040
- [Batch Check](#batch-check)
41+
- [Client Batch Check](#client-batch-check)
4142
- [Expand](#expand)
4243
- [List Objects](#list-objects)
4344
- [Streamed List Objects](#streamed-list-objects)
@@ -934,6 +935,9 @@ response = await fga_client.batch_check(ClientBatchCheckRequest(checks=checks),
934935
# ]
935936
```
936937

938+
##### Client Batch Check
939+
940+
937941
If you are using an OpenFGA version less than 1.8.0, you can use `client_batch_check`,
938942
which calls `check` in parallel. It will return `allowed: false` if it encounters an error, and will return the error in the body.
939943
If 429s or 5xxs are encountered, the underlying check will retry up to 3 times before giving up.
@@ -1283,6 +1287,30 @@ async def main():
12831287
```
12841288

12851289

1290+
### Error Handling
1291+
1292+
The SDK provides comprehensive error handling with detailed error information and convenient helper methods.
1293+
1294+
Key features:
1295+
- Operation context in error messages (e.g., `[write]`, `[check]`)
1296+
- Detailed error codes and messages from the API
1297+
- Helper methods for error categorization (`is_validation_error()`, `is_retryable()`, etc.)
1298+
1299+
```python
1300+
from openfga_sdk.exceptions import ApiException
1301+
1302+
try:
1303+
await client.write([tuple])
1304+
except ApiException as e:
1305+
print(f"Error: {e}") # [write] HTTP 400 type 'invalid_type' not found (validation_error) [request-id: abc-123]
1306+
1307+
if e.is_validation_error():
1308+
print(f"Validation error: {e.error_message}")
1309+
elif e.is_retryable():
1310+
print(f"Temporary error - retrying... (Request ID: {e.request_id})")
1311+
```
1312+
1313+
12861314
### API Endpoints
12871315

12881316
Class | Method | HTTP request | Description
@@ -1407,29 +1435,6 @@ Class | Method | HTTP request | Description
14071435

14081436
This SDK supports producing metrics that can be consumed as part of an [OpenTelemetry](https://opentelemetry.io/) setup. For more information, please see [the documentation](https://github.com/openfga/python-sdk/blob/main/docs/opentelemetry.md)
14091437

1410-
### Error Handling
1411-
1412-
The SDK provides comprehensive error handling with detailed error information and convenient helper methods.
1413-
1414-
Key features:
1415-
- Operation context in error messages (e.g., `[write]`, `[check]`)
1416-
- Detailed error codes and messages from the API
1417-
- Helper methods for error categorization (`is_validation_error()`, `is_retryable()`, etc.)
1418-
1419-
```python
1420-
from openfga_sdk.exceptions import ApiException
1421-
1422-
try:
1423-
await client.write([tuple])
1424-
except ApiException as e:
1425-
print(f"Error: {e}") # [write] HTTP 400 type 'invalid_type' not found (validation_error) [request-id: abc-123]
1426-
1427-
if e.is_validation_error():
1428-
print(f"Validation error: {e.error_message}")
1429-
elif e.is_retryable():
1430-
print(f"Temporary error - retrying... (Request ID: {e.request_id})")
1431-
```
1432-
14331438
## Contributing
14341439

14351440
See [CONTRIBUTING](./CONTRIBUTING.md) for details.

test/error_integration_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
],
5454
}
5555

56+
5657
@pytest.mark.integration
5758
@pytest.mark.asyncio
5859
class TestErrorIntegration:

0 commit comments

Comments
 (0)