Skip to content

Conversation

@skshetry
Copy link
Contributor

@skshetry skshetry commented Feb 4, 2026

Relates to #9993

Change Description

Background

When the DeleteObjects API receives more than 1000 paths, it returns HTTP 500 Internal Server Error. This causes clients to retry the request unnecessarily since 5xx errors are typically retried.

Bug Fix

  1. Problem - DeleteObjects returns HTTP 500 for request size validation errors, causing unnecessary retries.

  2. Root cause - The size limit check was using http.StatusInternalServerError instead of a 4xx client error:

    if len(body.Paths) > DefaultMaxDeleteObjects {
    err := fmt.Errorf("%w, max paths is set to %d", ErrRequestSizeExceeded, DefaultMaxDeleteObjects)
    writeError(w, r, http.StatusInternalServerError, err)
    return
    }

    var lakectlDefaultRetryStatuses = ShouldRetryer{
    http.StatusTooManyRequests,
    http.StatusInternalServerError,
    http.StatusServiceUnavailable,
    }

  3. Solution - Return HTTP 400 Bad Request instead, matching AWS S3 behavior. This prevents unnecessary retries since 4xx errors indicate client errors that won't succeed on retry.

Testing Details

  • Existing unit tests pass
  • Code compiles successfully

Breaking Change?

No - this changes an error response code from 500 to 400, which is a more accurate status code for this validation error.

@skshetry skshetry added include-changelog PR description should be included in next release changelog minor-change Used for PRs that don't require issue attached labels Feb 4, 2026
Return HTTP 400 Bad Request when the number of paths exceeds the limit,
matching AWS S3 behavior. This prevents unnecessary retries since 4xx
errors are not retried by the client.

Relates to #9993
@skshetry skshetry force-pushed the fix/delete-objects-request-size-400 branch from 19c8b48 to d18fa8d Compare February 4, 2026 05:10
@github-actions github-actions bot added the area/testing Improvements or additions to tests label Feb 4, 2026
@skshetry skshetry requested a review from a team February 4, 2026 05:12
if len(body.Paths) > DefaultMaxDeleteObjects {
err := fmt.Errorf("%w, max paths is set to %d", ErrRequestSizeExceeded, DefaultMaxDeleteObjects)
writeError(w, r, http.StatusInternalServerError, err)
writeError(w, r, http.StatusBadRequest, err)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we have the test below, but I think BadRequest makes more sense here than InternalServerError, so I thought I'd propose.

Copy link
Contributor

@nopcoder nopcoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@skshetry skshetry merged commit d7d5fdb into master Feb 4, 2026
98 of 101 checks passed
@skshetry skshetry deleted the fix/delete-objects-request-size-400 branch February 4, 2026 06:52
@skshetry skshetry self-assigned this Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/testing Improvements or additions to tests include-changelog PR description should be included in next release changelog minor-change Used for PRs that don't require issue attached

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants