🧹 fix: harden request-body size handling and error unwrapping

Tighten oversized request handling across relay paths and make error matching reliable.

- Align `MAX_REQUEST_BODY_MB` fallback to `32` in request body reader and decompression middleware
- Stop ignoring `GetRequestBody` errors in relay retry paths; return consistent **413** on oversized bodies (400 for other read errors)
- Add `Unwrap()` to `types.NewAPIError` so `errors.Is/As` can match wrapped underlying errors
- `go test ./...` passes
This commit is contained in:
t0ng7u
2025-12-16 18:10:00 +08:00
parent 8e3f9b1faa
commit 8cb56fc319
4 changed files with 33 additions and 8 deletions

View File

@@ -94,6 +94,14 @@ type NewAPIError struct {
StatusCode int
}
// Unwrap enables errors.Is / errors.As to work with NewAPIError by exposing the underlying error.
func (e *NewAPIError) Unwrap() error {
if e == nil {
return nil
}
return e.Err
}
func (e *NewAPIError) GetErrorCode() ErrorCode {
if e == nil {
return ""