-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Issue: Incorrect gRPC status code for "request body too large" error
Problem Description
When executing storage write operations in Nakama and encountering the error "http: request body too large", the server returns an incorrect gRPC status code.
Current Behavior
When the error "http: request body too large" occurs, the following is returned:
- HTTP status code: 400 (or another appropriate code)
- gRPC status code:
3(INVALID_ARGUMENT)
Expected Behavior
When the error "http: request body too large" occurs, the following should be returned:
- HTTP status code: 400 (or another appropriate code)
- gRPC status code:
8(RESOURCE_EXHAUSTED)
Rationale
The "request body too large" error means that the request body size exceeds the allowed limit. This is a resource exhaustion error, not an invalid argument error. Semantically, this means that the operation cannot be performed due to resource constraints (request size exceeds the limit), which corresponds to the RESOURCE_EXHAUSTED status according to the gRPC specification.
Context
Client code may require special handling for this situation. Due to the incorrect gRPC status code, we are forced to check the error message text against a constant string, as there is no other reliable way to identify this specific error case. This approach is fragile, as it depends on exact message text matching, which may change.
Steps to Reproduce
- Execute a storage write operation (
WriteStorageObjectsAsync) - Attempt to write an object whose size exceeds the server's allowed limit
- Check the returned gRPC status code in the
ApiResponseException
Expected Result After Fix
After the server is fixed:
- gRPC status code should be
8(RESOURCE_EXHAUSTED) - Error handling will occur automatically based on the correct status code
- Client code will be able to reliably identify this error without checking the message text