Harden parseErrorCodeFromS3 to never throw on non-XML responses#12986
Conversation
Return "" instead of throwing on parse failures since many HTTP error responses (502/503 HTML pages, empty bodies) are not XML. Remove unused backup_parse_s3_response_failure error code. Fix const-ref parameter, constexpr badRequestCode, and add unit tests.
There was a problem hiding this comment.
Pull request overview
Hardens S3 error-code extraction so non-XML HTTP error bodies (e.g., 502/503 HTML pages or empty responses) do not raise errors, and adds regression tests to ensure parsing remains best-effort.
Changes:
- Update
parseErrorCodeFromS3to return""on parse failures instead of throwing, and add diagnostic tracing for non-XML parse exceptions. - Remove the now-unused
backup_parse_s3_response_failureerror code. - Minor cleanup (
constexprforbadRequestCode) and add unit tests covering valid/invalid XML, empty, HTML, and garbage responses.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| flow/include/flow/error_definitions.h | Removes unused backup/restore error code tied to the old throwing behavior. |
| fdbclient/S3BlobStore.cpp | Makes S3 error parsing non-throwing, improves const-correctness, and adds unit tests for common non-XML failure modes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
gxglass
left a comment
There was a problem hiding this comment.
I think this is a relatively contained PR and a good candidate for immediate backporting
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr-macos on macOS Ventura 13.x
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr on Linux RHEL 9
|
|
Failures are tests/slow/GcGenerations.toml, tests/restarting/from_7.3.0/ConfigureTestRestart-1.toml, tests/restarting/from_7.3.0/ConfigureTestRestart-2.toml, tests/fast/PrivateEndpoints.toml. main is a bit dirty. These seem unrelated.... |
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr-macos on macOS Ventura 13.x
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr on Linux RHEL 9
|
|
tests/fast/SwizzledRollbackSideband.toml failed. Unrelated. |
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
|
tests/restarting/from_7.3.0/ConfigureStorageMigrationTestRestart-1.toml Unrelated |
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr-macos on macOS Ventura 13.x
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
…e#12986) Add parseErrorCodeFromS3 function that safely extracts S3 error codes from XML responses, returning "" instead of throwing on parse failures since many HTTP error responses (502/503 HTML pages, empty bodies) are not XML. Wire it into doRequest_impl error handling to log S3ErrorCode and detect bad requests. Add unit tests. (cherry picked from commit 7388f54)
…e#12986) Add parseErrorCodeFromS3 function that safely extracts S3 error codes from XML responses, returning "" instead of throwing on parse failures since many HTTP error responses (502/503 HTML pages, empty bodies) are not XML. Wire it into doRequest_impl error handling to log S3ErrorCode and detect bad requests. Add unit tests. (cherry picked from commit 7388f54)
…12997) * Harden parseErrorCodeFromS3 to never throw on non-XML responses (#12986) Add parseErrorCodeFromS3 function that safely extracts S3 error codes from XML responses, returning "" instead of throwing on parse failures since many HTTP error responses (502/503 HTML pages, empty bodies) are not XML. Wire it into doRequest_impl error handling to log S3ErrorCode and detect bad requests. Add unit tests. (cherry picked from commit 7388f54) * Log all S3 4xx client errors, not just 400 Widen the S3 error logging from only HTTP 400 to all 4xx client errors (403, 404, 409, etc). Remove unused badRequestCode variable. Rename trace event from S3BlobStoreBadRequest to S3BlobStoreClientError. * Fix trace * Simplify S3BlobStore request error handling (merge PR #13001) * Remove separate S3BlobStoreClientError event, use existing event --------- Co-authored-by: michael stack <stack@duboce.com>
…pple#12997) * Harden parseErrorCodeFromS3 to never throw on non-XML responses (apple#12986) Add parseErrorCodeFromS3 function that safely extracts S3 error codes from XML responses, returning "" instead of throwing on parse failures since many HTTP error responses (502/503 HTML pages, empty bodies) are not XML. Wire it into doRequest_impl error handling to log S3ErrorCode and detect bad requests. Add unit tests. (cherry picked from commit 7388f54) * Log all S3 4xx client errors, not just 400 Widen the S3 error logging from only HTTP 400 to all 4xx client errors (403, 404, 409, etc). Remove unused badRequestCode variable. Rename trace event from S3BlobStoreBadRequest to S3BlobStoreClientError. * Fix trace * Simplify S3BlobStore request error handling (merge PR apple#13001) * Remove separate S3BlobStoreClientError event, use existing event --------- Co-authored-by: michael stack <stack@duboce.com>
* Harden parseErrorCodeFromS3 to never throw on non-XML responses 7.3 (#12997) - 7.3 * Harden parseErrorCodeFromS3 to never throw on non-XML responses (#12986) - main Add parseErrorCodeFromS3 function that safely extracts S3 error codes from XML responses, returning "" instead of throwing on parse failures since many HTTP error responses (502/503 HTML pages, empty bodies) are not XML. Wire it into doRequest_impl error handling to log S3ErrorCode and detect bad requests. Add unit tests. (cherry picked from commit 7388f54) * Log all S3 4xx client errors, not just 400 Widen the S3 error logging from only HTTP 400 to all 4xx client errors (403, 404, 409, etc). Remove unused badRequestCode variable. Rename trace event from S3BlobStoreBadRequest to S3BlobStoreClientError. * Fix trace * Simplify S3BlobStore request error handling (merge PR #13001) * Remove separate S3BlobStoreClientError event, use existing event
…pple#12997) * Harden parseErrorCodeFromS3 to never throw on non-XML responses (apple#12986) Add parseErrorCodeFromS3 function that safely extracts S3 error codes from XML responses, returning "" instead of throwing on parse failures since many HTTP error responses (502/503 HTML pages, empty bodies) are not XML. Wire it into doRequest_impl error handling to log S3ErrorCode and detect bad requests. Add unit tests. (cherry picked from commit 7388f54) * Log all S3 4xx client errors, not just 400 Widen the S3 error logging from only HTTP 400 to all 4xx client errors (403, 404, 409, etc). Remove unused badRequestCode variable. Rename trace event from S3BlobStoreBadRequest to S3BlobStoreClientError. * Fix trace * Simplify S3BlobStore request error handling (merge PR apple#13001) * Remove separate S3BlobStoreClientError event, use existing event --------- Co-authored-by: michael stack <stack@duboce.com>
Return "" instead of throwing on parse failures since many HTTP error responses (502/503 HTML pages, empty bodies) are not XML. Remove unused backup_parse_s3_response_failure error code. Fix const-ref parameter, constexpr badRequestCode, and add unit tests.
I ran the ctests against s3