Skip to content

Core: Read REST response headers without regard to case - #17979

Open
moomindani wants to merge 1 commit into
apache:mainfrom
moomindani:fix/rest-response-header-case
Open

Core: Read REST response headers without regard to case#17979
moomindani wants to merge 1 commit into
apache:mainfrom
moomindani:fix/rest-response-header-case

Conversation

@moomindani

Copy link
Copy Markdown
Contributor

Closes #17978.

Freshness-aware table loading did nothing at all when the catalog server wrote the ETag response header in any spelling other than ETag. HTTPClient collected response headers into a map keyed by the name exactly as received, RESTSessionCatalog copied that into another HashMap and read the tag back as HttpHeaders.ETAG, so a server that sent etag left tableCache empty. No later load sent If-None-Match, and nothing surfaced the fact that the server had answered with a tag.

Header field names are case-insensitive (RFC 9110 section 5.1), and lowercase is mandatory in HTTP/2 (RFC 9113 section 8.2.1), so a client cannot key on the spelling a server happened to choose. Both maps are now case-insensitive, which fixes the lookup without changing what callers see otherwise.

I hit this against an Armeria-based catalog server, which writes HTTP/1 header names in their lowercase HTTP/2 form by default: the server returned a correct ETag for a conditional loadTable and the client could not see it. The same applies to any server reached over HTTP/2.

Tests:

  • TestHTTPClient.responseHeadersAreReadWithoutRegardToCase has the mock server answer with etag and asserts the map handed to the caller resolves both spellings, covering the collection point.
  • TestFreshnessAwareLoading.freshnessAwareLoadingWithLowercaseETagHeader drives a catalog through an adapter that reports its response headers lowercased, and asserts the table cache is still populated and the second load is answered from it, covering the consumer.
  • Both fail on an unfixed tree. ./gradlew :iceberg-core:test --tests "org.apache.iceberg.rest.*" passes.

Freshness-aware table loading did nothing when the catalog server wrote the
ETag response header in any spelling other than ETag. HTTPClient collected
response headers into a map keyed by the name exactly as received and
RESTSessionCatalog copied that into another HashMap and read the tag back as
HttpHeaders.ETAG, so a server sending etag left the table cache empty, no
later load sent If-None-Match, and nothing surfaced that the server had
answered with a tag.

Header field names are case-insensitive (RFC 9110) and lowercase is mandatory
in HTTP/2 (RFC 9113), so the spelling a server chose cannot decide whether a
client finds the header. Both maps are now case-insensitive.
@github-actions github-actions Bot added the core label Sep 6, 2026

@uros-b uros-b left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like a correct, minimal, RFC 9110-grounded fix for a real HTTP/2 and lowercase-header-normalization interop bug: both collection points must be case-insensitive for the ETag round-trip to work, both edits are present, and both new tests trace the full path and fail on an unfixed tree. The sole red CI check is an unrelated Gradle-wrapper infra flake. Otherwise, should be good to go! Thank you @moomindani.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

REST: Freshness-aware loading breaks when the server writes the ETag header in lowercase

2 participants