Files
seaweedFS/weed/util
Chris Lu 0ce31daf90 Fix #7305: Return 400 BadDigest instead of 500 InternalError for MD5 mismatch (#7306)
When an S3 upload has a mismatched Content-MD5 header, SeaweedFS was
incorrectly returning a 500 Internal Server Error instead of the proper
400 Bad Request with error code BadDigest (per AWS S3 specification).

Changes:
- Created weed/util/constants/filer.go with error message constants
- Added ErrMsgBadDigest constant for MD5 mismatch errors
- Added ErrMsgOperationNotPermitted constant for WORM permission errors
- Added ErrBadDigest error code with proper 400 status code mapping
- Updated filerErrorToS3Error() to detect MD5 mismatch and return ErrBadDigest
- Updated filer autoChunk() to return 400 Bad Request for MD5 mismatch
- Refactored error handling to use switch statement for better readability
- Ordered error checks with exact matches first for better maintainability
- Updated all error handling to use centralized constants
- Added comprehensive unit tests

All error messages now use constants from a single location for better
maintainability and consistency. Constants placed in util package to avoid
architectural dependency issues.

Fixes #7305
2025-10-08 14:24:10 -07:00
..
2023-11-26 11:47:20 -08:00
2025-08-21 08:28:07 -07:00
2019-11-17 11:40:36 +08:00
2022-08-15 01:05:35 -07:00
2025-08-31 23:23:02 -07:00
2021-04-27 10:37:24 +08:00
2024-08-07 10:42:00 -07:00
2021-08-20 18:38:18 +08:00
2025-06-03 22:46:10 -07:00
2025-06-03 22:46:10 -07:00
2021-09-01 02:45:42 -07:00
2021-09-01 02:45:42 -07:00
2022-09-25 17:43:42 -07:00
2022-09-25 17:43:42 -07:00
2022-09-25 13:34:55 -07:00
2023-09-21 23:51:32 -07:00
2021-04-27 10:37:24 +08:00
2024-07-07 23:44:36 -07:00
2023-10-01 11:36:27 -07:00
2024-10-31 08:40:05 -07:00