Skip to content

feat: Add ETag to responses and evaluate If-None-Match Header - #1509

Merged
Midor merged 29 commits into
mainfrom
pb/etag
Nov 27, 2025
Merged

Midor merged 29 commits into
mainfrom
pb/etag

Conversation

@Midor

@Midor Midor commented Nov 24, 2025 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • HTTP ETag support for caching; responses may include ETag headers.
    • Table API accepts If-None-Match values and can return 304 Not Modified when metadata is unchanged.
    • Conditional load-table responses now surface a NotModified variant when applicable.
  • Tests

    • Added unit and end-to-end tests for ETag generation, parsing, and conditional load-table behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Nov 24, 2025 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Adds ETAG support end-to-end: xxh3-based ETag generation in iceberg-ext, If-None-Match parsing, a new LoadTableResultOrNotModified enum to represent 304 vs 200 flows, and updates across workspace deps, router/service/loader layers and tests to wire ETag-aware behavior.

Changes

Cohort / File(s) Summary
Workspace Dependencies
Cargo.toml
Added workspace dependencies: aws-credential-types, aws-sdk-s3, aws-sigv4, google-cloud-token, tracing-test, unicase, and xxhash-rust.
Iceberg-ext: hashing & response
crates/iceberg-ext/Cargo.toml, crates/iceberg-ext/src/catalog/rest/table.rs
Added xxhash-rust (xxh3) dependency; introduced public ETag wrapper and create_etag(text: &str) -> ETag; replaced macro-based IntoResponse for LoadTableResult with explicit IntoResponse that injects an ETag header when metadata_location is present; added axum-gated imports and unit tests for ETag behavior.
Iceberg-ext: re-exports
crates/iceberg-ext/src/catalog/mod.rs
Re-exported ETag and create_etag from table into the catalog public surface.
API re-exports
crates/lakekeeper/src/api/iceberg/mod.rs
Re-exported LoadTableResultOrNotModified into iceberg v1 public API.
API: ETag parsing & enum
crates/lakekeeper/src/api/iceberg/v1/tables.rs
Added public enum LoadTableResultOrNotModified and its IntoResponse impl; added pub fn parse_if_none_match(headers: &HeaderMap) -> Vec<ETag> and helper fn parse_etags(etags: &str) -> Vec<ETag>; changed TablesService::load_table signature to accept etags: Vec<ETag> and return LoadTableResultOrNotModified; tests expanded for parsing and enum behavior.
Server: router & service wiring
crates/lakekeeper/src/server/tables.rs
Updated TablesService::load_table impls and call sites to accept etags: Vec<ETag> and return LoadTableResultOrNotModified; imports and tests updated to pattern-match new enum.
Server: loader ETag checks
crates/lakekeeper/src/server/tables/load_table.rs
Added get_etag and etag_already_present helpers; checks If-None-Match etags early and returns NotModified when matched; changed load_table signature to accept etags and return LoadTableResultOrNotModified; tests added/updated for NotModified and wildcard cases.
Tests (integration/unit)
crates/iceberg-ext/src/catalog/rest/table.rs (tests), crates/lakekeeper/src/api/iceberg/v1/tables.rs (tests), crates/lakekeeper/src/tests/soft_deletion.rs
Added tests for create_etag, response ETag header presence, parse_if_none_match/parse_etags edge cases, and updated tests to pass etags and handle LoadTableResultOrNotModified variants.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Router
    participant Service
    participant Loader

    Client->>Router: GET /tables/{id} (If-None-Match: ...)
    Router->>Router: parse_if_none_match(headers) → Vec\<ETag>
    Router->>Service: load_table(params, ..., etags)
    Service->>Loader: load_table(..., etags)
    alt etag matches current table
        Loader-->>Service: NotModified (with current ETag)
        Service-->>Router: NotModified
        Router->>Router: IntoResponse → 304 + ETag header
        Router-->>Client: 304 Not Modified + ETag
    else not matched
        Loader-->>Service: LoadTableResult (includes metadata_location)
        Service-->>Router: LoadTableResult
        Router->>Router: IntoResponse -> create_etag(metadata_location)
        Router-->>Client: 200 OK + JSON body + ETag
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Areas needing extra attention:
    • Ensure create_etag (iceberg-ext) and server get_etag use identical algorithm/format and quoting.
    • parse_if_none_match / parse_etags handling of weak tags, spaces, multiple header values, and *.
    • Correct propagation of etags: Vec<ETag> through router → service → loader and trait signature changes.
    • IntoResponse implementations for LoadTableResultOrNotModified to ensure proper status/headers and backward compatibility.
    • Tests updated to cover NotModified and normal flows thoroughly.

Possibly related PRs

Poem

🐰 I hop through metadata, swift and light,
I hash each path with xxh3 might.
If nothing changed, a quiet reply —
"304" I send, no bytes to fly.
A rabbit's cache, snug and bright ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main changes: adding ETag support to responses and implementing If-None-Match header evaluation.
Docstring Coverage ✅ Passed Docstring coverage is 93.55% which is sufficient. The required threshold is 80.00%.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cla-assistant

cla-assistant Bot commented Nov 24, 2025 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@cla-assistant

cla-assistant Bot commented Nov 24, 2025

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (3)
crates/iceberg-ext/src/catalog/rest/table.rs (1)

173-207: Consider extracting duplicate test helper to a common module.

The create_table_metadata_mock function appears to be duplicated from crates/lakekeeper/src/api/iceberg/v1/tables.rs (lines 803-837). Consider extracting this to a shared test utility module to avoid code duplication and ensure consistency across tests.

crates/lakekeeper/src/server/tables/load_table.rs (1)

27-43: ETag helper semantics are sound; consider tiny refinements

get_etag correctly derives an ETag from TabularInfo.metadata_location using the same create_etag helper as the HTTP response path, so 200/304 paths stay consistent. etag_already_present’s wildcard logic (* meaning “any representation”) also matches typical If-None-Match semantics. Two minor nits you could optionally address later:

  • etags.contains(&"*".to_string()) allocates on each call; etags.iter().any(|e| e == "*") would avoid that.
  • If you ever reuse etag_already_present for resources that legitimately have no ETag, returning NotModifiedResponse(etag.unwrap_or_default()) would emit an empty ETag; today that can’t happen because active tables always have a metadata location, but it’s worth keeping the invariant in mind.
crates/lakekeeper/src/api/iceberg/v1/tables.rs (1)

409-416: parse_etags / parse_if_none_match normalization is robust; consider multi-header support later

The parsing helpers:

  • Strip surrounding whitespace, outer and inner quotes, and leading W/ where present, so callers always see bare tag tokens (or "*").
  • Split on commas and filter out empty/whitespace-only segments, which matches how typical If-None-Match headers are formatted.
  • Are thoroughly exercised by the tests, including mixed quoting, weak/strong tags, doubled quotes, and empty/space-only headers.

One optional improvement if you ever need stricter RFC handling: parse_if_none_match currently uses headers.get(header::IF_NONE_MATCH) and therefore only sees a single header value; if multiple If-None-Match headers are ever emitted separately, you could switch to get_all(...).iter() and join them with commas before passing into parse_etags.

Also applies to: 457-478

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 621dfa4 and 8dc820d.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (9)
  • Cargo.toml (4 hunks)
  • crates/iceberg-ext/Cargo.toml (1 hunks)
  • crates/iceberg-ext/src/catalog/mod.rs (1 hunks)
  • crates/iceberg-ext/src/catalog/rest/table.rs (2 hunks)
  • crates/lakekeeper/src/api/iceberg/mod.rs (1 hunks)
  • crates/lakekeeper/src/api/iceberg/v1/tables.rs (8 hunks)
  • crates/lakekeeper/src/server/tables.rs (20 hunks)
  • crates/lakekeeper/src/server/tables/load_table.rs (14 hunks)
  • crates/lakekeeper/src/tests/soft_deletion.rs (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-19T07:33:45.608Z
Learnt from: c-thiel
Repo: lakekeeper/lakekeeper PR: 1285
File: crates/lakekeeper/src/service/storage/mod.rs:1354-1356
Timestamp: 2025-08-19T07:33:45.608Z
Learning: In test code (#[cfg(test)]), unreachable!() is often appropriate when it indicates a programming error in test setup, unlike production code where graceful error handling is preferred. Test helpers should fail fast when called with invalid configurations.

Applied to files:

  • crates/lakekeeper/src/api/iceberg/v1/tables.rs
📚 Learning: 2025-11-07T15:17:22.491Z
Learnt from: c-thiel
Repo: lakekeeper/lakekeeper PR: 1484
File: crates/lakekeeper/src/server/tables.rs:820-859
Timestamp: 2025-11-07T15:17:22.491Z
Learning: In the lakekeeper codebase, when refreshing namespaces during table operations (e.g., in `refresh_warehouse_and_namespace` in `crates/lakekeeper/src/server/tables.rs`), the refresh should use `namespace.namespace_ident()` rather than `namespace.namespace_id()`. This ensures that if a namespace is renamed between the initial fetch and the refresh, the operation fails rather than silently continuing with the renamed namespace. User intent is bound to the namespace ident they specified, not the underlying stable namespace ID.

Applied to files:

  • crates/lakekeeper/src/server/tables.rs
🧬 Code graph analysis (5)
crates/iceberg-ext/src/catalog/rest/table.rs (1)
crates/lakekeeper/src/api/iceberg/v1/tables.rs (2)
  • create_table_metadata_mock (804-838)
  • from (68-73)
crates/lakekeeper/src/api/iceberg/mod.rs (1)
crates/lakekeeper/src/implementations/postgres/tabular/table/mod.rs (1)
  • tables (491-491)
crates/iceberg-ext/src/catalog/mod.rs (1)
crates/iceberg-ext/src/catalog/rest/table.rs (1)
  • create_etag (109-112)
crates/lakekeeper/src/api/iceberg/v1/tables.rs (1)
crates/iceberg-ext/src/catalog/rest/table.rs (1)
  • into_response (116-124)
crates/lakekeeper/src/server/tables/load_table.rs (1)
crates/iceberg-ext/src/catalog/rest/table.rs (1)
  • create_etag (109-112)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: test
  • GitHub Check: clippy
  • GitHub Check: check-generated-openapi-matches
  • GitHub Check: sqlx-check
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: security_audit
🔇 Additional comments (12)
crates/iceberg-ext/Cargo.toml (1)

41-41: LGTM!

The xxhash-rust dependency with the xxh3 feature is appropriate for efficient ETag generation.

crates/iceberg-ext/src/catalog/mod.rs (1)

31-31: LGTM!

The create_etag function is appropriately exposed as part of the public API from the table module.

crates/iceberg-ext/src/catalog/rest/table.rs (1)

1-8: LGTM!

The imports are properly feature-gated for axum and include the necessary xxhash functionality.

crates/lakekeeper/src/tests/soft_deletion.rs (1)

14-15: Soft-deletion test adapts correctly to new ETag-aware API

Using Vec::new() for etags and explicitly matching on LoadTableResultOrNotModified::LoadTableResult is the right way to keep this test focused on table restoration while treating NotModified as an unexpected outcome.

Also applies to: 221-237

crates/lakekeeper/src/api/iceberg/mod.rs (1)

25-32: Re-export of LoadTableResultOrNotModified is consistent with the new tables API

Adding LoadTableResultOrNotModified to the v1 tables re-exports keeps the public iceberg API aligned with the new load-table semantics and avoids scattered import paths.

crates/lakekeeper/src/server/tables/load_table.rs (2)

47-55: Early If-None-Match short‑circuit is correct and consistent with the ETag format

The updated load_table:

  • Accepts etags: Vec<String> from the router and normalizes the current ETag by stripping quotes before comparison, which matches how parse_if_none_match normalizes incoming values.
  • Short-circuits to LoadTableResultOrNotModified::NotModifiedResponse(etag) before doing the heavier metadata load when any provided tag (or *) matches the current ETag.
  • Still falls back to the full LoadTableResult path, wrapped in the enum, so existing callers can destructure and keep their previous behavior.

This keeps the hot path simple while enabling correct 304 responses without changing the storage/catalog logic.

Also applies to: 72-93, 161-170


243-337: ETag-specific tests cover the critical behaviors

The new test setup (setup_simple_table) plus the three NotModified tests exercise:

  • Single matching ETag.
  • Multiple ETags where only one matches.
  • Wildcard * behavior.

All call load_table directly with parsed-style ETags (trimmed and with/without wildcard), aligning with how parse_if_none_match feeds the server. Treating any NotModified as an error in the pre-existing snapshot tests (by matching on LoadTableResultOrNotModified::LoadTableResult) is also a good guardrail against accidental behavior changes.

Also applies to: 917-1025

crates/lakekeeper/src/server/tables.rs (2)

363-382: Service implementation cleanly forwards the new ETag parameters and result type

Updating TablesService::load_table to accept etags: Vec<String> and return Result<LoadTableResultOrNotModified> while delegating directly into load_table::load_table keeps this module free of ETag logic and aligned with the v1 API trait.


1755-1926: Test suite updates correctly adapt to LoadTableResultOrNotModified

Across the test module:

  • CatalogServer::load_table calls now pass Vec::new() for etags, clearly signaling “no If-None-Match” in existing tests.
  • Call sites consistently destructure LoadTableResultOrNotModified via LoadTableResultOrNotModified::LoadTableResult(...), panicking on NotModified, which preserves the original test intent and ensures new cache behavior doesn’t silently mask regressions.

The helper load_table function returning LoadTableResult in test code is also updated appropriately, centralizing the pattern for other tests to reuse.

Also applies to: 2039-2059, 2202-2222, 2269-2289, 2414-2431, 2512-2530, 2645-2668, 2810-2881, 2919-2937, 3007-3024, 3139-3156, 3183-3214, 4289-4311

crates/lakekeeper/src/api/iceberg/v1/tables.rs (3)

1-2: LoadTableResultOrNotModified and its IntoResponse implementation look correct

The enum cleanly separates the normal LoadTableResult path from the 304 path:

  • NotModifiedResponse(etag) builds a 304 Not Modified with the ETag header set, mirroring what clients expect from conditional GETs.
  • LoadTableResult delegates to the existing LoadTableResult::into_response, preserving the existing response shape and ETag behavior for 200s.

Given that all constructors in this PR pass ETags generated via create_etag, the etag.parse().unwrap() should be safe in practice; if you ever allow arbitrary strings in NotModifiedResponse, consider downgrading the unwrap() to an expect with a clear message.

Also applies to: 7-12, 76-95


127-136: Router and trait signature changes wire If-None-Match through as intended

  • TablesService::load_table now accepts an etags: Vec<String> and returns Result<LoadTableResultOrNotModified>, aligning the trait with the new cache-aware semantics.
  • The GET handler for /.../tables/{table} calls parse_if_none_match(&headers) and forwards the resulting vector into load_table, so HTTP If-None-Match headers directly influence the server-side ETag check.
  • Existing routes and other trait methods are untouched, so compatibility is preserved for non-load-table operations.

The change is minimal, well-contained, and keeps the HTTP/trait boundary clean.

Also applies to: 185-188, 251-276


499-508: New tests give good coverage of ETag responses and If-None-Match parsing

  • test_load_table_result_or_not_modified_from_not_modified_response and the async test comparing bodies via extract_body_from_response validate that:
    • The 304 path sets the correct status and ETag header.
    • The 200 path via LoadTableResultOrNotModified::LoadTableResult is byte-for-byte equivalent to the existing LoadTableResult response.
  • The parse_if_none_match test set covers:
    • Missing header.
    • Single values, with/without spaces.
    • Weak tags.
    • * wildcard.
    • Many pathological quoting combinations and empty/whitespace-only cases.

This gives strong confidence that the ETag plumbing will behave correctly across a wide variety of client header formats.

Also applies to: 758-838, 840-973, 975-1009

Comment thread Cargo.toml Resolved
impl IntoResponse for LoadTableResult {
fn into_response(self) -> axum::http::Response<axum::body::Body> {
// self.metadata_location
let metadata_location = self.metadata_location.clone().unwrap_or_default();

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.

I don't think we should return an ETag for staged tables (tables without metadata location), as fetching them would yield 404 anyway.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Logic is now implemented. See #1509 (comment)

let etag = create_etag(&metadata_location);

let mut header = HeaderMap::new();
header.insert(header::ETAG, etag.parse().unwrap());

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.

We should handle the error gracefully and not panic. Lets use tracing::error to log the error and not return anything.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is also added in the current implementation. It will still return an empty HeaderMap and the JSON body, but it will log this error with the suggested method.

Midor and others added 2 commits November 24, 2025 14:53
Add error handling for parsing into HeaderValue.
Add tests for checking correct json body.
…og/rest/table.rs

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
coderabbitai[bot]
coderabbitai Bot previously approved these changes Nov 24, 2025
@Midor

Midor commented Nov 24, 2025

Copy link
Copy Markdown
Member Author

@coderabbitai Added the handling of multiple separate If-None-Match Headers, concating all into a single vector.

@coderabbitai

coderabbitai Bot commented Nov 24, 2025

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Read the implementation of parse_if_none_match to see how multiple headers are handled
cat crates/lakekeeper/src/api/iceberg/v1/tables.rs | grep -A 30 "pub fn parse_if_none_match"

Length of output: 952


@Midor Thanks for the update! I've reviewed the implementation and it looks great. Using get_all(header::IF_NONE_MATCH) correctly handles multiple separate If-None-Match headers, and the flat_map(parse_etags) ensures that each header value is also parsed for comma-separated ETags. This approach properly follows the HTTP/1.1 specification (RFC 7232), which states that multiple headers with the same field name should be treated equivalently to a single header with comma-separated values.

The implementation correctly handles all valid scenarios:

  • Single header with one ETag: If-None-Match: "abc123"
  • Single header with multiple ETags: If-None-Match: "abc123", "def456"
  • Multiple headers: If-None-Match: "abc123" + If-None-Match: "def456"
  • Combinations of the above

Nice work! 👍

@Midor

Midor commented Nov 24, 2025

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 24, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8dc820d and 8e62542.

📒 Files selected for processing (2)
  • crates/iceberg-ext/src/catalog/rest/table.rs (2 hunks)
  • crates/lakekeeper/src/api/iceberg/v1/tables.rs (8 hunks)
🧰 Additional context used
🧠 Learnings (6)
📚 Learning: 2025-11-07T15:17:22.491Z
Learnt from: c-thiel
Repo: lakekeeper/lakekeeper PR: 1484
File: crates/lakekeeper/src/server/tables.rs:820-859
Timestamp: 2025-11-07T15:17:22.491Z
Learning: In the lakekeeper codebase, when refreshing namespaces during table operations (e.g., in `refresh_warehouse_and_namespace` in `crates/lakekeeper/src/server/tables.rs`), the refresh should use `namespace.namespace_ident()` rather than `namespace.namespace_id()`. This ensures that if a namespace is renamed between the initial fetch and the refresh, the operation fails rather than silently continuing with the renamed namespace. User intent is bound to the namespace ident they specified, not the underlying stable namespace ID.

Applied to files:

  • crates/iceberg-ext/src/catalog/rest/table.rs
📚 Learning: 2025-08-19T07:33:45.608Z
Learnt from: c-thiel
Repo: lakekeeper/lakekeeper PR: 1285
File: crates/lakekeeper/src/service/storage/mod.rs:1354-1356
Timestamp: 2025-08-19T07:33:45.608Z
Learning: In test code (#[cfg(test)]), unreachable!() is often appropriate when it indicates a programming error in test setup, unlike production code where graceful error handling is preferred. Test helpers should fail fast when called with invalid configurations.

Applied to files:

  • crates/iceberg-ext/src/catalog/rest/table.rs
  • crates/lakekeeper/src/api/iceberg/v1/tables.rs
📚 Learning: 2025-09-25T18:44:19.943Z
Learnt from: c-thiel
Repo: lakekeeper/lakekeeper PR: 1267
File: .github/workflows/integration_test_matrix.yml:43-43
Timestamp: 2025-09-25T18:44:19.943Z
Learning: In the Lakekeeper project, the integration_test_workflow.yml dynamically parses test configuration from the test_name parameter format (e.g., spark_openfga-1.9.2) rather than requiring explicit mappings for each version. New version numbers can be added to the test matrix without modifying the workflow file itself.

Applied to files:

  • crates/iceberg-ext/src/catalog/rest/table.rs
📚 Learning: 2025-09-23T18:51:43.107Z
Learnt from: c-thiel
Repo: lakekeeper/lakekeeper PR: 1364
File: .github/workflows/integration_test_workflow.yml:59-59
Timestamp: 2025-09-23T18:51:43.107Z
Learning: In the Lakekeeper project, test configuration like SPARK_ICEBERG_VERSION is passed dynamically through the test matrix via test_name rather than being hardcoded as environment variables in the workflow files. This provides more flexibility for running different test configurations.

Applied to files:

  • crates/iceberg-ext/src/catalog/rest/table.rs
📚 Learning: 2025-10-13T10:31:34.544Z
Learnt from: c-thiel
Repo: lakekeeper/lakekeeper PR: 1435
File: crates/lakekeeper/src/service/catalog_store/namespace.rs:166-170
Timestamp: 2025-10-13T10:31:34.544Z
Learning: For the lakekeeper/lakekeeper repository: Do not flag or comment on potential compile errors. The maintainers have confirmed that all code that is pushed compiles successfully and is validated by their CI/CD pipeline.

Applied to files:

  • crates/iceberg-ext/src/catalog/rest/table.rs
📚 Learning: 2025-09-23T18:54:00.185Z
Learnt from: c-thiel
Repo: lakekeeper/lakekeeper PR: 1364
File: .github/workflows/release.yml:277-279
Timestamp: 2025-09-23T18:54:00.185Z
Learning: In the Lakekeeper project, the maintainers prefer dynamic test configuration through test matrix rather than hardcoded environment variables in workflow files. This approach allows testing multiple versions and configurations rather than being locked into a single version, which is considered superior to hardcoded environment variable approaches.

Applied to files:

  • crates/iceberg-ext/src/catalog/rest/table.rs
🧬 Code graph analysis (2)
crates/iceberg-ext/src/catalog/rest/table.rs (1)
crates/lakekeeper/src/api/management/mod.rs (1)
  • into_response (1287-1289)
crates/lakekeeper/src/api/iceberg/v1/tables.rs (1)
crates/iceberg-ext/src/catalog/rest/table.rs (3)
  • into_response (116-135)
  • etag (125-125)
  • create_table_metadata_mock (222-256)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: sqlx-check
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
🔇 Additional comments (6)
crates/iceberg-ext/src/catalog/rest/table.rs (2)

108-136: LGTM! ETag implementation properly handles edge cases.

The implementation correctly:

  • Generates ETags using xxh3_64 hashing
  • Returns early when metadata_location is None (staged tables)
  • Handles header parsing errors gracefully with logging
  • Uses idiomatic Rust patterns (let-else)

All previously raised concerns have been properly addressed.


145-257: Excellent test coverage!

The test suite thoroughly validates:

  • ETag generation correctness
  • Header presence for tables with metadata_location
  • Header absence for staged tables (None metadata_location)
  • JSON body serialization/deserialization

The create_table_metadata_mock helper is well-designed and promotes test maintainability.

crates/lakekeeper/src/api/iceberg/v1/tables.rs (4)

128-135: Well-designed API change for ETag support.

The signature changes properly integrate ETag support:

  • New etags parameter accepts parsed If-None-Match values
  • Return type LoadTableResultOrNotModified clearly represents 200 vs 304 responses
  • Router correctly extracts ETags via parse_if_none_match(&headers)

Also applies to: 274-274


457-479: Robust ETag parsing implementation with excellent test coverage.

The parsing functions correctly handle:

  • Multiple ETags in a single header (comma-separated)
  • Multiple separate If-None-Match headers
  • Weak ETags (W/ prefix)
  • Various quoting styles and edge cases

The implementation follows RFC 7232 requirements. The comprehensive test suite (lines 841-1025) validates correct behavior across all scenarios.


759-839: Good test coverage for the enum variants.

The tests properly validate:

  • NotModifiedResponse returns 304 with ETag header
  • LoadTableResult delegates correctly and returns 200
  • Response body extraction and comparison

The duplicated create_table_metadata_mock helper is appropriately documented (line 804) as necessary for package independence.


841-1025: Outstanding test coverage for ETag parsing!

The 14 test functions comprehensively validate:

  • Empty and missing headers
  • Single and multiple ETags
  • Weak ETags (W/ prefix)
  • Various quoting styles (including double quotes)
  • Whitespace handling
  • The special asterisk case
  • Multiple separate headers
  • Edge cases (empty strings, spaces only)

The test_parse_if_none_match_returns_multiple_values_with_mixed_styles test (lines 933-974) is particularly thorough, covering 12 different ETag format variations.

This level of coverage provides strong confidence in the implementation's correctness.

@Midor

Midor commented Nov 25, 2025

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 25, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
crates/lakekeeper/src/server/tables/load_table.rs (1)

27-40: ETag helper flow is correct; consider minor cleanups

  • get_etag correctly derives an Option<ETag> from TabularInfo.metadata_location and create_etag, which keeps the ETag tied to the metadata location/version.
  • etag_already_present correctly handles both exact matches and the * wildcard, and the normalization in the call site (as_str().trim_matches('"')) aligns with how If-None-Match is parsed elsewhere.
  • The early-return ETag check in load_table (before the heavier business logic) is well‑placed and the new tests for single match, multiple match, and wildcard cover the main scenarios.

Two minor, optional tweaks:

  • You could simplify the API by only calling etag_already_present when an ETag exists and dropping the Option parameter (i.e., fn etag_already_present(etags: &[ETag], etag: &ETag)), since the only caller already does the Option handling.
  • The TODO: Add handling for staged tables may no longer reflect current behavior (active tables only, staged become 404); consider either removing it or clarifying what additional behavior is intended.

Also applies to: 79-88, 913-1019

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e62542 and 968c298.

📒 Files selected for processing (5)
  • crates/iceberg-ext/src/catalog/mod.rs (1 hunks)
  • crates/iceberg-ext/src/catalog/rest/table.rs (2 hunks)
  • crates/lakekeeper/src/api/iceberg/v1/tables.rs (8 hunks)
  • crates/lakekeeper/src/server/tables.rs (21 hunks)
  • crates/lakekeeper/src/server/tables/load_table.rs (14 hunks)
🧰 Additional context used
🧠 Learnings (7)
📚 Learning: 2025-09-08T09:10:07.658Z
Learnt from: c-thiel
Repo: lakekeeper/lakekeeper PR: 1328
File: crates/lakekeeper/src/service/authz/implementations/openfga/mod.rs:103-112
Timestamp: 2025-09-08T09:10:07.658Z
Learning: The OpenFGAAuthorizer constructor in crates/lakekeeper/src/service/authz/implementations/openfga/mod.rs should maintain backward compatibility during the transition away from nil UUIDs. Hard assertions that would panic on nil UUID input should be avoided to prevent breaking existing deployments.

Applied to files:

  • crates/lakekeeper/src/api/iceberg/v1/tables.rs
📚 Learning: 2025-08-19T07:33:45.608Z
Learnt from: c-thiel
Repo: lakekeeper/lakekeeper PR: 1285
File: crates/lakekeeper/src/service/storage/mod.rs:1354-1356
Timestamp: 2025-08-19T07:33:45.608Z
Learning: In test code (#[cfg(test)]), unreachable!() is often appropriate when it indicates a programming error in test setup, unlike production code where graceful error handling is preferred. Test helpers should fail fast when called with invalid configurations.

Applied to files:

  • crates/lakekeeper/src/api/iceberg/v1/tables.rs
  • crates/iceberg-ext/src/catalog/rest/table.rs
📚 Learning: 2025-11-07T15:17:22.491Z
Learnt from: c-thiel
Repo: lakekeeper/lakekeeper PR: 1484
File: crates/lakekeeper/src/server/tables.rs:820-859
Timestamp: 2025-11-07T15:17:22.491Z
Learning: In the lakekeeper codebase, when refreshing namespaces during table operations (e.g., in `refresh_warehouse_and_namespace` in `crates/lakekeeper/src/server/tables.rs`), the refresh should use `namespace.namespace_ident()` rather than `namespace.namespace_id()`. This ensures that if a namespace is renamed between the initial fetch and the refresh, the operation fails rather than silently continuing with the renamed namespace. User intent is bound to the namespace ident they specified, not the underlying stable namespace ID.

Applied to files:

  • crates/iceberg-ext/src/catalog/rest/table.rs
  • crates/lakekeeper/src/server/tables/load_table.rs
  • crates/lakekeeper/src/server/tables.rs
📚 Learning: 2025-09-25T18:44:19.943Z
Learnt from: c-thiel
Repo: lakekeeper/lakekeeper PR: 1267
File: .github/workflows/integration_test_matrix.yml:43-43
Timestamp: 2025-09-25T18:44:19.943Z
Learning: In the Lakekeeper project, the integration_test_workflow.yml dynamically parses test configuration from the test_name parameter format (e.g., spark_openfga-1.9.2) rather than requiring explicit mappings for each version. New version numbers can be added to the test matrix without modifying the workflow file itself.

Applied to files:

  • crates/iceberg-ext/src/catalog/rest/table.rs
📚 Learning: 2025-09-23T18:51:43.107Z
Learnt from: c-thiel
Repo: lakekeeper/lakekeeper PR: 1364
File: .github/workflows/integration_test_workflow.yml:59-59
Timestamp: 2025-09-23T18:51:43.107Z
Learning: In the Lakekeeper project, test configuration like SPARK_ICEBERG_VERSION is passed dynamically through the test matrix via test_name rather than being hardcoded as environment variables in the workflow files. This provides more flexibility for running different test configurations.

Applied to files:

  • crates/iceberg-ext/src/catalog/rest/table.rs
📚 Learning: 2025-10-13T10:31:34.544Z
Learnt from: c-thiel
Repo: lakekeeper/lakekeeper PR: 1435
File: crates/lakekeeper/src/service/catalog_store/namespace.rs:166-170
Timestamp: 2025-10-13T10:31:34.544Z
Learning: For the lakekeeper/lakekeeper repository: Do not flag or comment on potential compile errors. The maintainers have confirmed that all code that is pushed compiles successfully and is validated by their CI/CD pipeline.

Applied to files:

  • crates/iceberg-ext/src/catalog/rest/table.rs
📚 Learning: 2025-09-23T18:54:00.185Z
Learnt from: c-thiel
Repo: lakekeeper/lakekeeper PR: 1364
File: .github/workflows/release.yml:277-279
Timestamp: 2025-09-23T18:54:00.185Z
Learning: In the Lakekeeper project, the maintainers prefer dynamic test configuration through test matrix rather than hardcoded environment variables in workflow files. This approach allows testing multiple versions and configurations rather than being locked into a single version, which is considered superior to hardcoded environment variable approaches.

Applied to files:

  • crates/iceberg-ext/src/catalog/rest/table.rs
🧬 Code graph analysis (4)
crates/lakekeeper/src/api/iceberg/v1/tables.rs (1)
crates/iceberg-ext/src/catalog/rest/table.rs (4)
  • into_response (138-159)
  • etag (147-147)
  • from (119-121)
  • from (125-127)
crates/iceberg-ext/src/catalog/rest/table.rs (1)
crates/lakekeeper/src/api/iceberg/v1/tables.rs (3)
  • from (66-71)
  • into_response (81-104)
  • etag (88-88)
crates/iceberg-ext/src/catalog/mod.rs (1)
crates/iceberg-ext/src/catalog/rest/table.rs (1)
  • create_etag (131-134)
crates/lakekeeper/src/server/tables.rs (2)
crates/lakekeeper/src/api/iceberg/v1/tables.rs (2)
  • load_table (138-145)
  • load_table (630-650)
crates/lakekeeper/src/server/tables/load_table.rs (1)
  • load_table (44-167)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
  • GitHub Check: clippy
  • GitHub Check: check-format
  • GitHub Check: sqlx-check
  • GitHub Check: test
  • GitHub Check: check-generated-openapi-matches
  • GitHub Check: docker / docker
  • GitHub Check: docker / docker
🔇 Additional comments (8)
crates/iceberg-ext/src/catalog/mod.rs (1)

27-32: Public ETag exports look consistent and low-risk

Re-exporting ETag and create_etag from rest::table cleanly exposes the new ETag API at the catalog module boundary; naming and placement among the existing table-related types is consistent. No changes needed.

crates/iceberg-ext/src/catalog/rest/table.rs (2)

108-134: ETag newtype and create_etag are well-scoped and type-safe

Wrapping the raw string in an ETag newtype with as_str and From impls gives good type-safety while staying lightweight. create_etag’s use of xxh3_64 plus returning a quoted hex string matches HTTP ETag expectations, and the unit test for a fixed input anchors the behavior. No changes needed.

Also applies to: 169-185


136-160: LoadTableResult IntoResponse correctly manages optional ETag

The new IntoResponse impl for LoadTableResult:

  • Omits the ETag header when metadata_location is None (staged tables), which aligns with the earlier discussion about not emitting ETags for staged resources.
  • Computes the ETag from metadata_location and injects it into the response headers when present.
  • Gracefully logs and skips the header on HeaderValue parse failure, instead of panicking.
  • Has solid test coverage for ETag presence, absence, and JSON body round‑trip.

This all looks correct and robust.

Also applies to: 185-243

crates/lakekeeper/src/api/iceberg/v1/tables.rs (3)

74-105: LoadTableResultOrNotModified models 200 vs 304 cleanly

The new enum and its IntoResponse impl make the two possible outcomes explicit:

  • NotModifiedResponse(ETag) yields a 304 Not Modified with an ETag header when parsing succeeds, and logs+omits the header on parse failure instead of panicking.
  • LoadTableResult delegates to the existing LoadTableResult::into_response, keeping behavior consistent.

The accompanying tests verify both branches and the parse-failure case. This is a nice improvement in clarity and safety.

Also applies to: 769-806, 1047-1055


137-146: Router and TablesService changes correctly thread ETags

Updating TablesService::load_table to accept etags: Vec<ETag> and return Result<LoadTableResultOrNotModified> matches the server implementation, and the router now passes parse_if_none_match(&headers) as the last argument. This keeps the HTTP layer thin while centralizing ETag handling in the service.

Existing callers within the file are updated consistently, and tests exercise the new signature via the router.

Also applies to: 261-286


467-490: If-None-Match parsing is robust and well-tested

parse_etags and parse_if_none_match provide a thorough normalization pipeline:

  • Handle multiple header instances (get_all) and comma‑separated lists within a single header.
  • Trim whitespace, outer quotes (including double‑quoting), and optional W/ prefixes.
  • Preserve the * wildcard as a distinct ETag value.
  • Filter out empty/whitespace‑only entries and ignore non‑UTF‑8 header values.

The extensive unit tests around these helpers cover single/multiple values, weak/strong tags, varied quoting styles, multiple header lines, empty and whitespace‑only headers, and mixed oddball formats. This looks solid and should interoperate well with real‑world clients.

Also applies to: 851-1044

crates/lakekeeper/src/server/tables.rs (2)

17-20: Server wiring for ETag-aware load_table is consistent

  • Importing ETag and LoadTableResultOrNotModified and updating the TablesService impl to take etags: Vec<ETag> and return the enum aligns this layer with the API contract.
  • Delegating directly to load_table::load_table keeps the server implementation thin and localized.

This glue code looks correct.

Also applies to: 43-45, 363-382


1894-1926: Test adjustments preserve existing semantics under the new enum

Across the test module:

  • Calls to CatalogServer::load_table now pass Vec::new() for the etags parameter, which means the existing tests explicitly exercise the “no conditional GET” behavior.
  • New pattern matches on LoadTableResultOrNotModified::LoadTableResult(...) assert that these flows still return full table metadata and would fail loudly if a NotModifiedResponse were accidentally returned.
  • The helper load_table function in the test module unwraps the enum back to LoadTableResult, minimizing churn in tests that don’t care about ETag semantics.

These updates keep the prior test intent intact while accommodating the new ETag-aware return type.

Also applies to: 2002-2061, 2399-2531, 2819-2940, 3007-3214, 4289-4311

coderabbitai[bot]
coderabbitai Bot previously approved these changes Nov 25, 2025
@github-actions

Copy link
Copy Markdown
Contributor

✅ PR Title Formatted Correctly

The title of this PR match the correct format. Thank you!

@Midor Midor linked an issue Nov 26, 2025 that may be closed by this pull request
@Midor

Midor commented Nov 26, 2025 •

Copy link
Copy Markdown
Member Author

Comparison between this implementation and Apache Iceberg

ETag Creation

The RFC 723 - Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests - 2.3. ETag mentions, that ETags need to be put in quotes, so strong ETags can be distinguished from weak ETags (containing a W/ as Prefix), and also from a wildcard *.

In the implemention from Apache Iceberg - ETagProvider the ETags are generated without those quotes. Also in the Unit-Tests They showed exactly this usage. And in some Implementations, which I guess are Test Fixtures they showed that it is used as-is and not quoted afterwards.

"If-None-Match" Header Comparison

To handle cases, where the "If-None-Match" is sent with an ETag missing the quotes, we extract the ETags and remove the surrounding quotes and so compare only the content. This ensures, that even if clients strip the quotes or have there own logic to rebuild the ETag, it should still work.

Even without this handling this shouldn't be a problem at all, as the implementation from the Test Fixtures (it is also the same for other cases in the same file) implies to take the incoming "If-None-Match" header and compare it directly against the previously generated ETag.
So the important point is to have the same generation logic for ETags during their creation and comparison.

Additional Note: Another change we have in comparison to Apache Iceberg is the following.

We also handle the case, that the "If-None-Match" header can be added multiple times to a request, whereas in the Test Fixtures only the first "If-None-Match" header is used, in which case some cache misses could happen.

Typically a sender is advised to send a single header with comma separated values instead of multiple headers, so this change should not be a big problem, except for the use-case of a single header with multiple comma separated values, which are also handled as-is in Apache Iceberg.

But it is also not forbidden, and so a recipient should be able to handle multiple headers the same way as comma separated values. See RFC 7230 - Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing - Field Order.

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.

feat: Support ETAGs in load table response

2 participants