Skip to content

fix(s3): guard ETag and version-id reads against missing headers#105

Merged
mikehorgan-dell merged 1 commit intomainfrom
fix/s3-response-handler-npe-on-error
May 5, 2026
Merged

fix(s3): guard ETag and version-id reads against missing headers#105
mikehorgan-dell merged 1 commit intomainfrom
fix/s3-response-handler-npe-on-error

Conversation

@mikehorgan-dell
Copy link
Copy Markdown
Member

@mikehorgan-dell mikehorgan-dell commented May 5, 2026

Summary

S3ResponseHandler.handleResponseHeaders ran unconditionally on every response. Two header reads inside it weren't null-safe:

  • ETag (MPU part PUT): on a non-2xx part response the server omits ETag. The handler then called mpuTask.put(partNum, null) on a ConcurrentHashMap, which throws NPE. The exception surfaced as misleading Premature channel closure warnings and masked the actual upstream 4xx/5xx failure.
  • x-amz-version-id (versioning enabled): on any response without the header, the literal string "null" was appended to the item name, compounding ~null~null~... across retries.

Both branches now early-out when the header is absent. Behavior is unchanged on success responses.

handleResponseHeaders unconditionally recorded the part ETag into the
parent MPU task's context map (a ConcurrentHashMap, which rejects null
values). On any non-2xx part-PUT response the ETag header is absent,
producing a NullPointerException that surfaced as misleading "Premature
channel closure" warnings and obscured the underlying server failure.

The versioning branch had a parallel issue: a missing x-amz-version-id
header caused the literal string "null" to be appended to the item
name, compounding "~null~null~..." across retries.

Both branches now skip mutation when the header is absent. Adds a
regression test covering each case.
@mikehorgan-dell mikehorgan-dell merged commit f51958e into main May 5, 2026
6 checks passed
@mikehorgan-dell mikehorgan-dell mentioned this pull request May 5, 2026
3 tasks
@mikehorgan-dell mikehorgan-dell deleted the fix/s3-response-handler-npe-on-error branch May 6, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant