Skip to content

feat(iceberg): add AWS Glue Data Catalog + S3 Tables catalog modes - #1451

Merged
aaj3f merged 27 commits into
mainfrom
feat/iceberg-glue-sigv4
Oct 9, 2026
Merged

aaj3f merged 27 commits into
mainfrom
feat/iceberg-glue-sigv4

Conversation

@aaj3f

@aaj3f aaj3f commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds two native-AWS-SDK catalog modes to the Iceberg/R2RML graph-source path — AWS Glue Data Catalog (--mode glue) and AWS S3 Tables (--mode s3tables) — so tables written through Glue (Athena, Spark, Trino, pyiceberg, …) can be read without a version-hint.text and without a REST catalog in front of them.

# mapping-driven: each rr:tableName is a Glue <database>.<table>
fluree iceberg map sales --mode glue --region us-east-1 --r2rml mappings/sales.ttl
fluree iceberg map sales --mode s3tables --table-bucket-arn arn:aws:s3tables:us-east-1:123456789012:bucket/analytics --r2rml mappings/sales.ttl

Today neither existing mode can read these tables: REST mode has no SigV4, which Glue's Iceberg REST endpoint requires, and Direct mode needs metadata/version-hint.text, which Glue-catalogued tables don't have (and Direct's listing fallback isn't implemented for S3 — S3IcebergStorage has list_dir but no list_files).

Approach

Both modes resolve the table's current metadata_location through the native AWS SDK (aws-sdk-glue GetTable / aws-sdk-s3tables GetTableMetadataLocation), and then the existing reader reads metadata, manifests and data from S3 with the ambient AWS credential chain. No hand-rolled SigV4, no request signing, no REST prefix — the SDK signs its own calls, and the standard AWS endpoint overrides (AWS_ENDPOINT_URL_GLUE, AWS_ENDPOINT_URL_S3TABLES, …) reach private endpoints and local mocks. The Glue pointer is authoritative, so an uncommitted or orphaned metadata file sitting next to the committed one is never read.

SDK-native rather than REST + SigV4 because, for a normally S3-authorized principal, neither Glue (IAM mode) nor S3 Tables vends credentials, so ambient reads suffice — and staying on the SDK keeps one signing/transport/credential path instead of a second, hand-rolled one. (I did weigh this again against main as it is today, since BigLake landed as an AuthConfig on REST — see the update comment; the SDK-native shape still seems right for this PR, with REST + SigV4 maybe the natural vehicle for Lake Formation vending in #1456.)

How it fits main (after the merge-up)

Glue and S3 Tables are catalog modes of the Iceberg source, and they go through the same machinery REST does rather than a parallel copy of it:

  • One loadTable ladder for every catalog (per-query snapshot pin, cross-query cache, the disk pointer rung, the deferred LazyS3Storage, the time-pin guard, the §2 fail-closed storage decision) — resolve_catalog_load_and_storage / catalog_session_storage over Arc<dyn SendCatalogClient>. The two caches that outlive a query (cross-query and disk pointer) are keyed by the source's config too, so a source re-created under the same name against another catalog never answers from the old one's entry.
  • One process-wide catalog-client cache (R2rmlCache::catalog_clients), so SDK clients aren't rebuilt per cache miss. A disk-pointer hit on a non-vending catalog builds its ambient storage without calling the catalog at all.
  • One onboarding client (catalog_client) behind browse, preview, sample, storage verify, and the provisional R2RML query; metadata is read from metadata_location when a catalog returns none inline.
  • One region resolution: the catalog API is called in region, else s3_region, else the SDK chain (S3 Tables: the bucket ARN's region); S3 reads use s3_region, else the catalog's region.
  • One catalog-mode dispatch for the CLI and both server builders (IcebergConnectionConfig::from_mode / IcebergCreateConfig::from_mode), and one set of validation rules (CatalogConfig::validate_aws_sdk_catalog) that the API layer delegates to.
  • Errors carry the SDK's full source chain (not service error); a missing table is TableNotFound, and a refused catalog call (including Glue's expired / unknown / badly-signed credential codes) is err:catalog/AccessDenied (403), the same typed error Delta/Unity uses. On the query path, AWS identities (arn:…) in any storage or catalog denial are redacted and the full text logged; onboarding and verify keep the full text.

Glue and S3 Tables refuse vended_credentials = true (as Direct does), refuse a region that isn't an AWS region code (it becomes part of the SDK's hostname), and S3 Tables refuses a region that contradicts its bucket ARN. Every mode other than REST refuses REST-only settings (catalog auth, warehouse, a request for vended credentials) on the CLI, server and Python, rather than silently ignoring them. Browse lists only Iceberg tables, across every page.

Also in this PR

Glue made a few REST-path gaps visible, and since each would otherwise have become its own issue, they're fixed here too:

  • A catalog's refusal is typed. A REST catalog's 403 (or a 401 that survives the token refresh) was an untyped string — a 500 on queries, a 400 in onboarding. It's now err:catalog/AccessDenied (403), the same error Glue/S3 Tables and Delta/Unity raise, naming the table. The message keeps the Catalog request failed (<status>) wording hosts classify verify failures by.
  • Materialize / incremental scans go through the shared catalog path. prepare_iceberg_scan built REST clients by hand: it never hydrated SecretRef auth (so such a source couldn't be materialized at all), and it skipped the §2 credential decision (so a vended-required source whose catalog vended nothing was read with the process's ambient identity, though queries on it refuse). REST, Glue and S3 Tables now share one arm with the query path's client and storage decision.
  • /info row counts for every catalog, not just REST: Glue/S3 Tables counts come from the metadata file, through the query path's caches. A mapping-defined source's placeholder table (MAPPING_DEFINED_TABLE) is no longer listed.
  • Python: map_iceberg(..., glue=fluree.Glue(region=...)) / s3_tables=fluree.S3Tables(arn), through the same mode parser as the CLI and server — which also fixes mapping-driven REST sources (no table) in Python, which failed validation before.
  • storage-credentials (apache/iceberg #10722): REST loadTable now parses the standardized top-level storage-credentials array, ahead of the legacy config map, and the two duplicated loadTable parse sites are factored into one parse_load_table_response. The longest matching prefix is final, and its entry layers over the top-level config: connection settings (region, endpoint, path-style) still come from config unless the entry overrides them, while credential keys come only from the entry. So an entry with no static keys (e.g. remote signing) means no credentials, and §2 refuses the read rather than falling back to keys the catalog didn't scope to this table. Not hit by the SDK-native path; it's a latent 403 for any REST catalog that vends this way.

Tests

  • it_iceberg_glue_moto (new, runs in CI): replays a committed Glue-written fixture into moto (a local mock of S3, Glue and S3 Tables) and reads it through the public API — a table via GetTable (50), the current metadata among three (200), the Glue pointer over an uncommitted 00099 metadata file (100, not 0), a two-table join from one mapping (200), materialize scans (full / incremental / pinned) and a @snapshot: query, /info counts and tables, clear errors for a missing table and a Hive table, browse, and preview; and in s3tables mode, a table resolved via GetTableMetadataLocation (50), a missing table's error, and browse. The test job gets a pinned motoserver/moto service; glue_moto_is_configured_in_ci fails if the job's marker is set without the endpoint, so a skip can't read as a pass.
  • Wire-level refusals (runs in every test job, no moto): a wiremock endpoint serves AWS's own error shapes to the Glue and S3 Tables SDK clients and checks each denial / not-found reaches the caller typed and naming the table.
  • scripts/glue-local/: the CLI-level harness the test came from (moto + pyiceberg's GlueCatalog, no AWS account, no Docker). check.sh target grades a fluree binary; write_fixture.sh regenerates the CI fixture.
  • Unit tests for the SDK error classification, Glue metadata_location extraction, region resolution and validation, the S3 Tables ARN, mode parsing (including the REST-only refusal on every surface), storage-credentials precedence and layering, the config-keyed cache key, and query-path redaction. The live AWS tests (it_glue_live, it_glue_sdk_reads) are #[ignore]d and env-gated, like the other live Iceberg tests.

Follow-ups

Follow-up: #1456 — Lake-Formation-vended credentials for LF-governed Glue tables read by a restricted principal (ambient reads 403 there).

Not in this PR (both already filed): #2038 and #2039, the R2RML loader findings the harness turned up. In fluree/solo, once this lands in a release or pin: opening glue / s3tables as catalog types, and teaching its verify classifier the Glue catalog-denial wording (today it would read an AccessDeniedException as a storage denial).

Two native-AWS-SDK catalog modes for the Iceberg/R2RML graph-source path, at
parity with REST (Polaris/Snowflake) and Direct:

  fluree iceberg map gs --mode glue     --table db.tbl --region us-east-1 --r2rml m.ttl
  fluree iceberg map gs --mode s3tables --table ns.tbl --table-bucket-arn arn:... --r2rml m.ttl

Both resolve the table's metadata_location via the native AWS SDK (aws-sdk-glue
GetTable / aws-sdk-s3tables GetTableMetadataLocation) and read metadata/manifests
/data from S3 with the ambient credential chain, reusing the existing direct.rs
reader + from_default_chain. No aws-sigv4, no request signing, no REST prefix, no
vended-credential parsing.

Rationale: for a normally S3-authorized principal, neither Glue DC (IAM mode) nor
S3 Tables vends credentials, so ambient reads suffice; and staying on the AWS SDK
keeps consistent signing/transport paths rather than a hand-rolled REST+SigV4
client. Validated against a live Glue + S3 Tables harness (offline config tests +
exact-count SPARQL e2e incl. multi-table joins and a dangling-FK check).

- fluree-db-iceberg: GlueSdkCatalogClient + S3TablesSdkCatalogClient
  (catalog/aws_sdk.rs); CatalogConfig::Glue/S3Tables (serde glue/s3tables) —
  variant ungated, SDK impl aws-gated. read_glue example; offline config tests.
- fluree-db-api: CatalogMode::Glue/S3Tables + to_iceberg_gs_config + two r2rml
  scan-path arms mirroring Direct.
- fluree-db-cli / fluree-db-server: --mode glue|s3tables (+ --region,
  --catalog-id, --table-bucket-arn) on `iceberg map`, local and remote.
- docs: graph-sources + CLI reference.

Follow-ups: Lake-Formation-governed (vended-cred) Glue, and catalog browse for
Glue/S3Tables.
@aaj3f
aaj3f force-pushed the feat/iceberg-glue-sigv4 branch from 7c83c7c to d777a13 Compare July 7, 2026 16:24
aaj3f added 2 commits July 7, 2026 13:06
…query snapshot pin

Before this, only map/query/list/info/drop worked for glue/s3tables; the
read-only onboarding/introspection surface hard-rejected them, and the query
path lacked the REST arm's per-query snapshot pin + catalog caches.

Onboarding/introspection (catalog browse, table preview, R2RML auto-generate,
mapping validate):
- API: `rest_catalog_client` -> `catalog_client`, returning a boxed
  `SendCatalogClient` per mode (RestCatalogClient / GlueSdkCatalogClient /
  S3TablesSdkCatalogClient; Direct still rejected — no catalog to browse).
  Preview fetches + parses table metadata from S3 via `metadata_location` when
  the catalog returns no inline metadata (the SDK loadTable does), reusing the
  scan-path reader. generate/validate call preview per table, so they unblock
  transitively — no edits needed there.
- Server: `IcebergConnectionRequest` gains region/catalog_id/table_bucket_arn;
  `build_iceberg_connection` gains glue/s3tables arms.

Query-time (correctness + perf):
- glue/s3tables scans now resolve loadTable through the same per-query snapshot
  pin + cross-query loadTable cache as REST (`sdk_resolve_load_table`), so every
  scan in a query reads one pinned Iceberg snapshot (was: independent per-scan
  SDK loads could observe different snapshots if the table committed mid-query),
  and the SDK client is built only on a genuine cache miss (was: rebuilt + a
  fresh GetTable/GetTableMetadataLocation per scan).

Validated live: browse + preview against Glue (`examples/glue_onboarding.rs`);
SPARQL e2e counts unchanged (300/60000/6/20000). Offline: iceberg_catalog +
server route tests pass.
…3Tables

Captures the PR's acceptance criteria as assertions (previously only exercised by
hand-run examples), matching the repo's it_gcs_sdk_reads.rs live-test convention.

- fluree-db-iceberg/tests/it_glue_sdk_reads.rs: SDK catalog load_table -> ambient
  S3 read -> scan row count, for Glue and S3 Tables. Env-gated
  (FLUREE_GLUE_IT_* / FLUREE_S3TABLES_IT_*); skipped when unset, so no live
  dependency in CI. Asserts an exact row count when FLUREE_*_EXPECT_ROWS is set.
- fluree-db-api/tests/it_glue_live.rs: catalog browse + table preview via the
  public API, asserting browse lists the database and preview returns a schema.
- catalog/aws_sdk.rs: factor the Glue metadata_location extraction into a pure fn
  with offline unit tests (present + missing-key error) — CI-level coverage of
  the one bit of the Glue read path that previously had none.

Verified live against the sandbox harness: Glue dim_store=300, S3 Tables
dim_geography=200, browse (3 namespaces / 11 tables), preview (8 columns, v2).
@aaj3f
aaj3f force-pushed the feat/iceberg-glue-sigv4 branch from 4acab4e to dbbd901 Compare July 7, 2026 17:59
…EST loadTable

VendedCredentials only read vended S3 creds from the loadTable response's legacy
top-level `config` map, never the standardized top-level `storage-credentials`
array (apache/iceberg #10722) that S3 Tables / Lake-Formation-vended Glue / newer
Iceberg REST catalogs return. Such a response yielded `credentials = None`, so the
scan fell through to ambient creds and 403'd on the backing bucket — a permissions
error masquerading as a parse gap.

- `VendedCredentials::from_load_table_response(response, metadata_location)`:
  checks `storage-credentials` FIRST (spec-normative precedence), picking the
  longest prefix that yields *usable* static creds (a remote-signing-only entry
  carries no `s3.*` keys and is skipped), then falls back to the flat `config` map.
- Factor the two duplicated REST loadTable parse blocks (the `CatalogClient`
  (?Send) and `SendCatalogClient` impls) into one shared `parse_load_table_response`
  — preserves the inline `metadata` + `config` passthrough; fixes once, kills the
  duplication.
- Offline fixtures: precedence, longest-usable-prefix, non-matching-prefix ->
  config fallback, legacy config, malformed entries, none.

Not hit by #1451's SDK-native AWS path (ambient by design); benefits spec-compliant
REST vending catalogs (Polaris/Unity/Snowflake). The remaining follow-up
(SDK-native Lake-Formation vended creds for Glue) is captured as an audit-hardened
spec, deferred to a stacked PR.
async fn list_tables(&self, namespace: &str) -> Result<Vec<String>> {
let out = self
.client
.get_tables()

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.

These four list ops (get_databases/get_tables here, and list_namespaces/list_tables in the S3 Tables client) only read the first page. All are paginated — Glue defaults to 100 results + next_token, S3 Tables returns a continuation token — so browse silently truncates any catalog with >100 databases/tables. Loop on the token or use .into_paginator().send().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. All four list ops page through now (into_paginator() on GetDatabases / GetTables / ListNamespaces / ListTables), in the merge commit 148b70ef9. While I was in there, Glue GetTables also keeps only Iceberg tables, using the same metadata_location test load_table applies, so browse can't offer a Hive table that would only fail on load.

Comment thread fluree-db-api/src/graph_source/r2rml.rs Outdated
Ok(match self {
SdkCatalog::Glue { region, catalog_id } => Box::new(
fluree_db_iceberg::catalog::GlueSdkCatalogClient::new(
region.as_deref(),

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.

The catalog client is built with only the mode region, but the S3 storage in the same scan arm (and the browse path in catalog_client) falls back region → io.s3_region. If a user sets only io.s3_region, GetTable resolves via the default-chain region while S3 reads use io.s3_region — mismatched, and it contradicts the CatalogConfig::Glue.region doc ("falls back to ... io.s3_region"). Thread io.s3_region into SdkCatalog so the fallback matches.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You were right, and it was actually a bit worse once main's newer callers were counted: four sites with three different precedences. There's now one resolution in fluree_db_iceberg::config (CatalogConfig::aws_catalog_region / IcebergGsConfig::storage_io) that the scan path, the onboarding routes and /info all use. The Glue/S3 Tables API is called in region, else s3_region, else the SDK chain (S3 Tables uses the bucket ARN's region and refuses a region that contradicts it). S3 reads use s3_region, else the catalog's region. That last bit flips the original precedence for the data reads. I think an explicit s3_region should win there, since the data can live in another region than the catalog, but happy to talk it through if you see it differently.

}
}

// Fall back to the legacy flat top-level `config` map.

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.

Edge case in this fallback: if the only prefix-matching storage-credentials entry is remote-signing-only (no static s3.* keys) and a legacy top-level config carries static creds, we skip the matching entry and fall back to config's static creds — which can contradict the catalog's intent to remote-sign that prefix. Rare shape, likely fine, but worth a note on the precedence.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I went a step further than a note here, fwiw. The longest matching prefix is now final: if it's remote-signing-only (no static s3.* keys), we return no credentials and §2 refuses the read, rather than falling back to a shorter entry or to the legacy config map. Both of those would be credentials the catalog didn't scope to this table. It's its own commit (bcc22892c) with tests for both shapes (longest_prefix_without_static_keys_yields_no_credentials, matching_remote_signing_entry_does_not_fall_back_to_legacy_config), so if you think fail-closed is too strict for that shape I'm happy to drop it back to a doc note.

@bplatz bplatz 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.

Several comments inline, approving so you don't have to wait after reviewing them.

@aaj3f

aaj3f commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

Backlog-sweep nudge: this has been approved since 7/7 but is now conflicting and ~7 weeks stalled, and #1456 (Lake-Formation vended credentials) is explicitly unstartable until it lands. The rebase is over the BYO-IAM credential work (#1500/#1503/#1514, e.g. 210cf4833) — and for what it's worth, LF vending composes with the STS AssumeRole grant rail that landed there (fluree-db-api/src/vended_credentials.rs) rather than being replaced by it, so I don't think the stall has invalidated the design.

One thing the sweep flagged that raises the stakes a bit: the storage-credentials-array parse fix that #1456 describes as "resolved in #1451" is not on main (rest.rs is still from_config_map-only) — because this never merged. So that fix either lands with the rebase or needs splitting out and tracking on its own; right now it's in limbo where the issue tracker says it's handled and the code says otherwise.

aaj3f added 12 commits October 8, 2026 12:40
Brings the Glue / S3 Tables catalog modes up to main (2,900 commits since
the 2026-07-06 merge-base) and re-threads them through main's current
Iceberg architecture rather than beside it.

Conflicts:
- Cargo.lock: main's lock, re-resolved with aws-sdk-glue 1.142.1 and
  aws-sdk-s3tables 1.54.0, the newest releases compatible with main's locked
  smithy runtime. The lock only gains those two packages; the PR's
  1.153.0 / 1.59.0 forced the shared AWS runtime (smithy-runtime, sigv4,
  aws-runtime) up under the HTTP/1.1-pinned S3 read path.
- Cargo.toml manifests, cli.rs, docs/graph-sources/iceberg.md: both sides.
- r2rml.rs, iceberg_catalog.rs: resolved by the re-threading below.

Re-threaded onto main's patterns:
- One loadTable ladder. main's REST ladder (per-query pin, cross-query
  cache, disk pointer rung, deferred LazyS3Storage, the #1896 time-pin
  guard, the section 2 fail-closed storage decision) now runs over
  Arc<dyn SendCatalogClient> for REST, Glue and S3 Tables
  (resolve_catalog_load_and_storage, catalog_session_storage). The PR's
  separate sdk_resolve_load_table copy, which predated the time-pin guard,
  is gone.
- One process-wide catalog-client cache (R2rmlCache::catalog_clients,
  shared_catalog_client); Glue/S3 Tables clients are no longer rebuilt on
  every cache miss. A disk-pointer hit on a non-vending catalog builds its
  ambient storage without calling the catalog.
- prepare_iceberg_scan (incremental / materialize) and ledger_info (/info
  catalog object) gained the arms main's new code needs.
- Onboarding: rest_catalog_client becomes async catalog_client for all five
  callers (browse, preview, sample, storage verify, provisional query);
  metadata is read from metadata_location when a catalog returns none
  inline (load_response_metadata).
- IcebergCreateConfig::to_iceberg_gs_config builds one IcebergGsConfig after
  the per-mode match, so delete / order_by / model / default_allow (added on
  main) cannot be dropped for a mode.
- One catalog-mode dispatch for the CLI and both server builders
  (IcebergConnectionConfig::from_mode / IcebergCreateConfig::from_mode,
  CatalogModeError rendered per surface). glue / s3tables take --table only
  when no --r2rml mapping names the tables, as rest does.
- One validation: the API delegates Glue/S3 Tables rules to
  CatalogConfig::validate_aws_sdk_catalog.

Review follow-ups (bplatz, 2026-07-07):
- Glue / S3 Tables listings page through every result.
- One region resolution (catalog call: region, then s3_region, then the SDK
  chain, S3 Tables using the ARN's region; S3 reads: s3_region, then the
  catalog's region), shared by the query and onboarding paths.

Also:
- SDK errors carry their source chain (not "service error"); not-found
  becomes TableNotFound, access-denied becomes the new
  IcebergError::CatalogAccessDenied, lifted to err:catalog/AccessDenied
  (403) on the eager and deferred paths.
- Glue browse lists only Iceberg tables.
- glue / s3tables refuse vended_credentials = true (as Direct does),
  refuse a region that is not an AWS region code (it becomes part of a
  hostname), and parse the S3 Tables ARN (all partitions) and refuse a
  region that contradicts it.
Review follow-up. Among the loadTable `storage-credentials` entries whose
prefix matches the table, the longest one is the catalog's decision for this
table. When that entry has no static s3.* keys (e.g. it asks for remote
signing, which this reader does not do), the result is now no credentials,
so the source's vended-credentials policy refuses the read (section 2
fail-closed). Before, the parser fell back to a shorter entry's keys or to
the legacy `config` map: credentials the catalog had not scoped to this
table. The legacy map still applies when no entry matches at all.
They skipped by returning early when their env vars were unset, so CI's
`nextest --all-features` run reported them as passing while they did
nothing. Mark them #[ignore] with the env they need, as every other live
Iceberg test is, and run them with --ignored. Use a placeholder AWS profile
in the run instructions.
Every page that listed the catalog modes as REST and Direct now covers Glue
and S3 Tables as well: the CLI and HTTP references (flags, fields, the
verify route), the stored config format, the mode chooser, credentials,
regions and endpoint overrides, and the lakehouse route table. The Glue
troubleshooting entry described errors that do not exist in the code; it is
replaced with the errors these modes actually return. The docs no longer
claim that Lake-Formation-governed Glue tables can be read in REST mode,
which has no SigV4 signing.
it_iceberg_glue_moto replays a committed fixture into moto (a local mock
of S3 and the Glue Data Catalog) and reads it through the public API:
- a table resolved through Glue GetTable;
- the current metadata file among three;
- the Glue pointer over an uncommitted 00099 metadata file;
- a two-table join named by one mapping;
- clear errors for a missing table and for a non-Iceberg (Hive) table;
- browse (Iceberg tables only) and preview (schema read from S3).

The fixture holds Iceberg tables written by pyiceberg's GlueCatalog
(pointer in `metadata_location`, no version-hint.text), exported with their
Glue registrations. The test seeds moto through the AWS SDK, so CI needs no
Python. Glue reaches moto through AWS_ENDPOINT_URL_GLUE and S3 through the
source's own s3_endpoint, which also pins that override.

CI: the `test` job gets a pinned motoserver/moto service and
FLUREE_GLUE_LOCAL_ENDPOINT. The test skips without it, and
glue_moto_is_configured_in_ci fails when the job's FLUREE_GLUE_MOTO marker
is set without the endpoint, as the live-bridge guard does. The `glue-moto`
feature keeps aws-sdk-glue out of other fluree-db-api test builds.

scripts/glue-local/ is the CLI-level harness this test came from, made
repo-generic. It runs moto plus pyiceberg locally (pinned in
requirements.txt), grades a fluree binary with check.sh, proves its
expected counts with selftest.sh, and regenerates the fixture with
write_fixture.sh. Each harness run gets a fresh TMPDIR so Fluree's disk
caches cannot answer from an earlier run, and env.sh sets no S3 endpoint
override, so check.sh proves --s3-endpoint is honored.
… Delta

The lakehouse troubleshooting row said S3 reads ignore AWS_PROFILE and
SSO. That is true of the Delta reader (object_store's from_env) and not of
Iceberg sources, Glue and S3 Tables included, which use the AWS SDK's
default chain. The aws_sdk module doc no longer claims that
Lake-Formation-governed Glue tables can be read in REST mode (#1456).
Fluree's Iceberg disk caches (catalog pointers, metadata, Parquet) live
under the temp dir and outlive the process. A re-run of
it_iceberg_glue_moto, or a nextest retry, could therefore answer from the
previous run's cache without asking Glue. It did: with the Glue client
mutated to read `previous_metadata_location`, the four count checks still
passed and only preview failed. The test now sets a fresh TMPDIR before
building Fluree. Under the same mutation the counts come back 0 / 100 /
0 / 0 and fail, as do the not-found and browse checks under their
mutations.
… internal error

A REST catalog's 403, or a 401 that survives the token refresh, was an
untyped `Catalog` string. Queries reported it as an internal error and
onboarding as a config error. It is now IcebergError::CatalogAccessDenied,
the same error a Glue / S3 Tables denial raises:
- each load_table names the table it was loading (name_denied_table);
- storage_query_error / storage_api_error lift it to
  QueryError::CatalogAccessDenied, HTTP 403, as Delta/Unity already do;
- the lift covers queries, the provisional R2RML query, preview, sample
  and browse.

The message keeps the "Catalog request failed (<status>): <body>" wording,
because hosts classify verify failures by it. Status codes for a REST
catalog denial change from 500 (query) / 400 (onboarding) to 403.
prepare_iceberg_scan (incremental and materialize scans) built REST
clients and storage by hand:
- it called create_provider_arc on un-hydrated auth, so a source whose
  catalog auth is a SecretRef could not be materialized at all;
- it skipped the section 2 credential decision, so a source requiring vended
  credentials whose catalog vended none was read with the process's
  ambient AWS identity, though queries on the same source refuse.

REST, Glue and S3 Tables now share one arm. It uses the process-wide
client (shared_catalog_client, which hydrates) and catalog_storage, which
is the query path's storage decision without the per-query client reuse
(refuse_unvended_read, then build_catalog_storage). The only sources that
newly fail are those whose queries already fail closed.

/info row counts were REST-only: they read the metadata inline from
loadTable, and Glue / S3 Tables return only its location. They now use the
same shared client and catalog_table_metadata (inline copy, then the query
path's caches, then one metadata read seeding those caches), so every
catalog source shows its counts.
it_iceberg_glue_moto now also covers, on `orders` (two appends of 100):
- materialize scans through prepare_iceberg_scan: a full scan (200), an
  incremental scan from the first snapshot (100), a scan pinned to it (100);
- a query pinned with `@snapshot:` (100);
- /info: catalog type `glue` and the row count read from the metadata file
  Glue points at (50).

Reverting /info to REST-only drops the count and fails the check.
- Iceberg / R2RML troubleshooting showed error types the code does not
  have (`SchemaMismatchError`, `IcebergConnectionError`,
  `R2RMLMappingError`). They are replaced with what the code actually does:
  - the map-time parse/compile errors;
  - the `/iceberg/r2rml/validate` diagnostic codes;
  - at query time, a missing column reads as null, so rows drop out quietly;
  - the catalog and storage denials.
- errors.md now documents err:catalog/AccessDenied (Iceberg REST, Glue /
  S3 Tables, Unity) beside the other 403s, and the Iceberg
  troubleshooting table covers a REST catalog's refusal.
- materialize / track make a query's credential decision; noted where they
  are documented.
- The server's own AWS identity is what reads direct / glue / s3tables
  sources (and REST ones with vended credentials off), so scope it to
  the tables it serves.
- server-integration.md / endpoints.md: `r2rml` is optional inline
  Turtle (it was documented as a path, as auto-generating a mapping when
  omitted, and as accepting JSON-LD inline), local `table_location`s are
  accepted under FLUREE_ICEBERG_LOCAL_ROOTS, and a failed REST connection
  test does not fail the request.
map_iceberg takes `glue=fluree.Glue(region=..., catalog_id=...)` or
`s3_tables=fluree.S3Tables(table_bucket_arn, region=...)` as the place the
tables are found, beside `table_location` and `catalog_uri`. Exactly one
must be given. The spec objects follow map_delta's `unity=fluree.Unity(...)`.

The native side now parses the mode with IcebergCreateConfig::from_mode,
the same dispatch the CLI and server use. That also fixes a REST source
whose tables all come from the mapping (no `table`): it failed validation
in Python with an empty table identifier, where the CLI and server
already accepted it.
@aaj3f

aaj3f commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

@bplatz — this had gone pretty stale (merge-base was 2026-07-06, ~2,900 commits behind), so I merged main into it rather than rebasing, so your review threads and their anchors stay put. Fair warning that this ended up being more than a conflict resolution: main grew a lot of Iceberg machinery since July, and the PR's Glue/S3 Tables arms had been built beside the REST path rather than through it, so I re-threaded them onto main's current shape. I did this with a lot of help from Claude, and I've tried to call out below every place where the result is a judgment call rather than a mechanical resolution, since a couple of them go a bit beyond what you asked for.

Your three inline comments: I replied in each thread. In short, the listings page through, region resolution is now one function shared by every path, and the storage-credentials remote-signing case fails closed (its own commit, bcc22892c, in case you'd rather it go back to a note).

Did the design still hold up against main?

I wondered whether, designing this from main today, we'd have done it as REST + SigV4 instead, since BigLake landed as an AuthConfig on the REST client. I don't think so, for this PR at least: the SDK-native path is what you approved; for ambient (IAM-mode) readers neither Glue nor S3 Tables vends anything, so REST's vending machinery buys nothing; and moto (and private endpoints generally) speak the Glue API but not Glue's Iceberg REST endpoint, so the local harness and the CI test below wouldn't be possible. Where REST + SigV4 might make sense is #1456 (Lake Formation vending), since that's exactly the case where the REST credential-delegation path would earn its keep — but that's a decision for that issue, not this PR.

What did change is how it plugs in. Glue and S3 Tables now go through main's single loadTable ladder rather than the PR's own sdk_resolve_load_table, which turned out to be a third copy that predated the time-pin guard on the cross-query cache (#1896). Concretely, in the merge commit (148b70ef9):

  • resolve_rest_load_and_storage / rest_session_storage became resolve_catalog_load_and_storage / catalog_session_storage over Arc<dyn SendCatalogClient>. REST behavior is unchanged; it's the same code with the client generalized.
  • R2rmlCache::rest_clients became catalog_clients, so the SDK clients get the same process-wide reuse REST clients do instead of an aws_config load per cache miss.
  • The disk pointer rung (PR-8) now covers every catalog mode. For a catalog that never vends, a forced deferred build skips the catalog call entirely, since storage is ambient regardless. I checked this one against moto: with the Parquet cache dropped and the pointer cache kept, a query made 0 Glue calls and 1 S3 GET, versus 1 + 4 cold.
  • main's three new REST-only onboarding callers (sample, storage verify, the provisional R2RML query) go through one async catalog_client, and preview/verify/sample read the metadata file when a catalog returns none inline.
  • prepare_iceberg_scan (incremental/materialize) and ledger_info needed arms the PR never saw. One was a compile error, the other would have silently returned no /info catalog object.
  • to_iceberg_gs_config builds one IcebergGsConfig after the per-mode match. The PR's Glue/S3 Tables struct literals predated delete / order_by / model / default_allow, and a per-arm literal is how a governance field like model quietly goes missing for one mode.
  • The mode-string dispatch existed in three copies (CLI, server map, server connection), so instead of adding Glue to each, it's now one IcebergConnectionConfig::from_mode / IcebergCreateConfig::from_mode. Glue/S3 Tables also take --table only when no --r2rml mapping names the tables, as REST does. The PR required --table even for a mapping-driven source, which a multi-table join can't satisfy.
  • SDK errors carry their source chain (the bare SdkError renders as service error). A missing table is TableNotFound, and a refused catalog call is a new IcebergError::CatalogAccessDenied, lifted to the existing err:catalog/AccessDenied (403) that Delta/Unity already produce, on both the eager and deferred paths.
  • Glue/S3 Tables refuse vended_credentials = true (as Direct does) instead of silently ignoring it, and refuse a region that isn't an AWS region code, since the SDK interpolates it into the hostname.

The textual conflicts themselves were small: the Cargo.toml manifests, cli.rs examples, and iceberg.md (kept both sides), plus Cargo.lock. For the lock I pinned aws-sdk-glue 1.142.1 / aws-sdk-s3tables 1.54.0, the newest releases compatible with main's locked smithy runtime. The PR's 1.153 / 1.59 would have bumped the shared AWS runtime (smithy-runtime, sigv4, aws-runtime) underneath the HTTP/1.1-pinned S3 read path, which I didn't want to do as a side effect of adding two catalogs. As-is the lock just gains the two packages.

Tests

The live it_glue_* tests returned early when their env vars were unset, with no #[ignore], so CI's nextest --all-features was reporting them as passing while doing nothing. They're #[ignore]d now, like the other live Iceberg tests (25f491354).

The new regression test is it_iceberg_glue_moto, and it runs in CI. It replays a committed fixture (Iceberg tables written by pyiceberg's GlueCatalog, so the pointer lives only in metadata_location and there's no version-hint.text) into moto, and reads it through the public API. The test job gets a pinned motoserver/moto service, and glue_moto_is_configured_in_ci fails if the job's marker is set without the endpoint, following the live-bridge guard. To make sure it isn't vacuous, I mutated the Glue client three ways (read previous_metadata_location, drop the not-found classification, let browse list Hive tables). Each mutation fails the test. The first one initially didn't fail the count checks, because the test was reusing the previous run's on-disk catalog caches and never asking Glue. The test now runs with a fresh TMPDIR (5f72ddc48), and under that mutation the counts come back 0 / 100 / 0 / 0 and fail.

scripts/glue-local/ is the CLI-level harness the test came from (moto + pyiceberg, no AWS account, no Docker), made repo-generic. It also regenerates the fixture.

scripts/glue-local against this branch (e8486de49) and against 4.2.3
$ scripts/glue-local/up.sh
moto up on http://127.0.0.1:5055 (pid 4488)
demo.customers         rows=  50 hint=no  metadata files=2 current=00001-6b4f5e…
demo.orders            rows= 200 hint=no  metadata files=3 current=00002-41eba0…
demo.customers_hinted  rows=  50 hint=yes metadata files=2 current=00001-af7fa2…
demo.orders_orphan     rows= 100 hint=no  metadata files=3 current=00001-4b2297…
manifest -> /Volumes/X10/glue-iceberg-local/manifest.json

$ FLUREE_BIN=fluree-4.2.3 selftest.sh
pass  st-customers = 50
pass  st-orders = 200
pass  st-orphan = 100
pass  st-join = 200
reseeded (hints removed)
selftest failures: 0

$ FLUREE_BIN=fluree-4.2.3 check.sh baseline
fluree: fluree 4.2.3   profile: baseline   
C1  | pass   | direct: Glue-written table + version-hint (control)        | expect 50                           | got 50
C2  | pass   | direct: Glue-written table, no version-hint                | expect ERR~version-hint             | got ERR: error: Query error: Internal error: Failed to resolve table metadata from s3://lake/warehouse/demo.db/customers: Metadata error: Failed to read version-hint.tex
C3  | pass   | glue: one table resolved via Glue GetTable                 | expect ERR~unknown catalog mode|unexpected argument | got ERR: error: unexpected argument '--region' found
C4  | pass   | glue: 3 metadata files; Glue's current one must win        | expect ERR~unknown catalog mode|unexpected argument | got ERR: error: unexpected argument '--region' found
C5  | pass   | glue: two-table R2RML join (orders->customers)             | expect ERR~unknown catalog mode|unexpected argument | got ERR: error: unexpected argument '--region' found
C6  | pass   | glue: catalog pointer beats an orphan 00099 file           | expect ERR~unknown catalog mode|unexpected argument | got ERR: error: unexpected argument '--region' found
C7  | pass   | glue: table missing from Glue -> clear error               | expect ERR~unknown catalog mode|unexpected argument | got ERR: error: unexpected argument '--region' found
C8  | pass   | glue: non-Iceberg Glue table -> clear error                | expect ERR~unknown catalog mode|unexpected argument | got ERR: error: unexpected argument '--region' found
C9  | pass   | direct, no hint, orphan file: never a silent wrong 0       | expect ERR~version-hint             | got ERR: error: Query error: Internal error: Failed to resolve table metadata from s3://lake/warehouse/demo.db/orders_orphan: Metadata error: Failed to read version-hint
failures: 0

$ FLUREE_BIN=<this branch> selftest.sh
pass  st-customers = 50
pass  st-orders = 200
pass  st-orphan = 100
pass  st-join = 200
reseeded (hints removed)
selftest failures: 0

$ FLUREE_BIN=<this branch> check.sh target
fluree: fluree 4.2.4-beta.1   profile: target   
C1  | pass   | direct: Glue-written table + version-hint (control)        | expect 50                           | got 50
C2  | info   | direct: Glue-written table, no version-hint                | expect INFO                         | got ERR: error: Query error: Internal error: Failed to resolve table metadata from s3://lake/warehouse/demo.db/customers: Metadata error: Failed to read version-hint.tex
C3  | pass   | glue: one table resolved via Glue GetTable                 | expect 50                           | got 50
C4  | pass   | glue: 3 metadata files; Glue's current one must win        | expect 200                          | got 200
C5  | pass   | glue: two-table R2RML join (orders->customers)             | expect 200                          | got 200
C6  | pass   | glue: catalog pointer beats an orphan 00099 file           | expect 100                          | got 100
C7  | pass   | glue: table missing from Glue -> clear error               | expect ERR~not found|EntityNotFound|does not exist | got ERR: error: Query error: Internal error: Failed to load table from catalog: Table not found: Glue table demo.nope not found: service error: EntityNotFoundException: 
C8  | pass   | glue: non-Iceberg Glue table -> clear error                | expect ERR~metadata_location|not an iceberg|table_type | got ERR: error: Query error: Internal error: Failed to load table from catalog: Metadata error: Glue table demo.hive_table is not an Iceberg table: it has no `metadata_l
C9  | pass   | direct, no hint, orphan file: never a silent wrong 0       | expect NOT0                         | got ERR: error: Query error: Internal error: Failed to resolve table metadata from s3://lake/warehouse/demo.db/orders_orphan: Metadata error: Failed to read version-hint
failures: 0

Gates for the touched crates are green locally:

  • fmt --check
  • clippy -D warnings on fluree-db-iceberg (all features), fluree-db-api (iceberg,aws,aws-testcontainers,glue-moto), fluree-db-server, fluree-db-cli, fluree-db-python
  • iceberg 329 unit tests
  • api graph_source + ledger_info 321
  • it_iceberg_glue_moto (13 checks, against moto) / it_graph_source_r2rml / it_iceberg_local_fs / it_iceberg_policy / it_iceberg_warehouse_root / harness_coverage
  • server iceberg routes + error mapping 44, CLI 251 + help-text + docs-coverage + iceberg integration
  • Python 339 + mypy + the nitpicky Sphinx build

The one thing I could not run here is it_iceberg_direct (LocalStack via testcontainers, and Docker isn't running on this machine), so CI is the first run of that one against these changes.

REST-path gaps Glue surfaced, fixed here rather than filed

A few things Glue made visible on the REST path would each have become a new issue, so with the backlog where it is I folded them in instead. These are separate commits after the merge, so they're easy to look at (or push back on) on their own:

  • d2d555bfe: a REST catalog's 403 (or a 401 that survives the token refresh) is now err:catalog/AccessDenied (403), the same as Glue/S3 Tables and Delta/Unity, instead of a 500 on queries and a 400 in onboarding. The message keeps the Catalog request failed (<status>) wording, since solo classifies verify failures by that text.
  • d3bfbcae4: prepare_iceberg_scan (materialize / incremental) built its REST client and storage by hand. That meant it never hydrated SecretRef auth, so a secret-ref'd source couldn't be materialized at all. It also skipped §2, so a vended-required source whose catalog vended nothing was read with the process's ambient identity, even though queries on the same source refuse. REST, Glue and S3 Tables now share one arm with the query path's client and storage decision, and the only sources that newly fail are the ones whose queries already fail closed. Same commit: /info row counts now cover every catalog, not just REST.
  • Python: map_iceberg takes glue=fluree.Glue(...) / s3_tables=fluree.S3Tables(...) through the same mode parser as the CLI and server. That also fixes mapping-driven REST sources (no table) in Python, which failed validation before.
  • it_iceberg_glue_moto now also covers materialize scans (full, incremental from a snapshot, pinned), a @snapshot: query, and /info over Glue.
  • Docs: the made-up troubleshooting blocks are replaced with real errors, and a few stale server-integration.md rows are fixed.

Not in this PR

Would you mind taking another look when you get a chance? I know the diff against your last review is big, but most of it is the re-threading above, and the commits after the merge are small and separate.

@aaj3f
aaj3f requested a review from bplatz October 8, 2026 22:09

@bplatz bplatz 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.

Thanks for the re-thread. Routing Glue and S3 Tables through the shared loadTable ladder is a big improvement over the parallel copy. I'm good with SDK-native for this PR: the moto test that runs in CI makes the case, and REST + SigV4 can come with #1456.

Approving, but please review the inline comments before merging. The first one, the storage-credentials entry dropping the top-level region and endpoint, is a regression for existing REST users and should be fixed here. The pointer-cache one needs either a fix or a decision and a docs note. The rest are smaller.

Two things that don't anchor to a line:

  • S3 Tables never runs in CI. Glue is covered end to end by moto. S3 Tables only has config and parse unit tests plus the ignored live test, so GetTableMetadataLocation, its NotFound/AccessDenied classification on the wire, and S3 Tables browse never execute in CI. If moto 5.2.3 supports s3tables, it's worth adding to the same test; if not, please file a follow-up.
  • Labels: the PR has none, so it lands under "Other Changes" in the release notes. Could you add area:iceberg and a feature label?

})
.max_by_key(|(prefix_len, _)| *prefix_len);

let config = match best_entry {

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.

When an entry matches, this builds the credentials from that entry's config alone, and the top-level config is never read. That's a regression for catalogs that put only the credential keys in the entry. Polaris (and Snowflake Open Catalog, which is built on it) puts s3.access-key-id / s3.secret-access-key / s3.session-token in the storage-credentials entry. client.region, s3.endpoint and s3.path-style-access are non-credential properties and go only into top-level config.

Parsing that shape here gives region None, endpoint None and path-style false. from_config_map(config) on main gives the catalog's values. So against a MinIO / S3-compatible store, reads go to real AWS S3 with MinIO keys, and a bucket outside the default region fails with a wrong-region error. Both work on main today. The Java S3FileIO layers the entry's properties over the table's rather than replacing them.

Suggested shape: start from the non-credential keys of the top-level config, overlay the matched entry, and take the credential keys only from the entry. That keeps the fail-closed rule from bcc22892c for an entry with no static keys. A test with region and endpoint only at top level next to a matching entry would pin it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @bplatz, you're right, and it's a real regression against main for the Polaris / Open Catalog shape: a matched entry replaced the top-level config wholesale, so client.region, s3.endpoint and s3.path-style-access just vanished. Fixed in 59bc07b with the shape you suggested (which I think is also what S3FileIO does): we start from the top-level config minus its credential keys, overlay the matched entry, and the credential keys (s3.access-key-id, s3.secret-access-key, s3.session-token, plus the two expiry keys) only ever come from the entry. So a remote-signing entry still yields no credentials and §2 still refuses, per bcc22892c, rather than reaching back for top-level keys the catalog didn't scope to this table.

a_matched_entry_keeps_the_tables_top_level_connection_settings pins region / endpoint / path-style at top level next to a matching entry, the entry's own region winning when it sets one, and the remote-signing case. Reverting the layering fails it.

.await
.map(|(storage, _)| storage)
} else {
// A catalog that never vends (Glue, S3 Tables)

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.

This needs a fix or an explicit decision. For Glue / S3 Tables, a pointer hit means queries never call the catalog until FLUREE_ICEBERG_LOADTABLE_PTR_TTL_SECS (default 300s) runs out. Within that window:

  • A table dropped in Glue, or a revoked glue:GetTable / Lake Formation grant, keeps being read with the ambient identity.
  • The pointer key is load_table_key(graph_source_id, namespace, table) and doesn't include the config, and the disk cache has no way to invalidate an entry. So dropping a source and re-creating it under the same name with a different region / catalog_id / ARN can serve the old table's data until the TTL expires. REST shares the key, but its forced build still calls loadTable under the new config, which re-checks.

Could the pointer key include a hash of the catalog config, the way the client cache does? Separately, I'm fine with the bounded staleness for the access-check case if it's documented, so a note in iceberg.md that Glue / S3 Tables can serve a cached pointer for up to the TTL without asking the catalog would cover it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I went with both here, the fix and the docs note.

The key (3efcd36): the two caches that outlive a query, the in-memory cross-query loadTable cache and the disk pointer, now key on load_table_key(gs, ns, table) plus the source config's fingerprint (cross_query_key, the same config_fingerprint the client cache already uses). So a source dropped and re-created under the same name with another region / catalog_id / ARN / URI can't answer from the old one's entry. The per-query session pin stays on the bare key, since a single query only ever sees one config. cross_query_keys_follow_the_catalog_config pins it, and fails if the fingerprint is dropped from the key.

The staleness: I'm fine with it bounded too, as long as it's written down, so iceberg.md → Connection Issues now says plainly that a table dropped from Glue / S3 Tables, or a revoked glue:GetTable / LF grant, is noticed only once the window passes, and that 0 on either TTL restores ask-every-time. configuration.md also gets a row for FLUREE_ICEBERG_LOADTABLE_PTR_TTL_SECS, which wasn't documented at all on main (its freshness note named the 60s TTL as the only freshness knob). One thing I tightened while writing it: the in-memory entry carries the vended credentials (CachedLoadTable, gated on creds_expired), so even a vending REST catalog isn't re-asked inside the 60s window. It's only past that, on a disk-pointer hit, that REST's forced build re-checks, and the docs say that rather than implying REST always does (2aa8808).

Comment thread docs/graph-sources/iceberg.md Outdated

For AWS S3 Tables, send `"mode": "s3tables"` and `"table_bucket_arn": "arn:aws:s3tables:us-east-1:123456789012:bucket/analytics"` in place of `region`; a Glue catalog in another account takes `"catalog_id": "123456789012"`. With `r2rml`, `table` may be omitted in `glue` and `s3tables` modes, as in `rest`: each `rr:tableName` names a table.

R2RML can be omitted to auto-generate a direct mapping. An optional `"model": "governance:main"` names the model ledger that governs the source (see [Access policy](#access-policy)). AWS credentials for `direct`, `glue` and `s3tables` modes come from the server's ambient AWS credential chain (`AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY`, `AWS_PROFILE`, `AWS_REGION`, or an attached instance role). See the [Graph Source Endpoints](../api/endpoints.md#graph-source-endpoints) section in the API reference for the complete request/response schema.

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.

This still says R2RML can be omitted to auto-generate a direct mapping. Nothing does that: without r2rml, the route calls create_iceberg_graph_source, and this PR's endpoints.md ("Omit to register a plain Iceberg source with no mapping") and server-integration.md say so. Please align this line with them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, thank you. Aligned it with endpoints.md / server-integration.md: "Without r2rml the source is registered as a plain Iceberg source with no mapping." (2aa8808)

Comment thread docs/graph-sources/iceberg.md Outdated
| Error | Cause |
|---|---|
| `… Table not found: Glue table sales.nope not found: …EntityNotFoundException…` | No such Glue database or table in this catalog and region. Check the `<database>.<table>` name, `--region`, and (for another account's catalog) `--catalog-id`. |
| ``… Glue table sales.t is not an Iceberg table (table_type=EXTERNAL_TABLE): it has no `metadata_location` parameter`` | The Glue table is a Hive / Parquet table, not an Iceberg one. Only tables that carry `metadata_location` can be mapped; catalog browse lists only those. |

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.

The (table_type=EXTERNAL_TABLE) part can't appear. glue_metadata_location reads table_type from the Parameters map, which a Hive table normally doesn't have, not from Glue's TableType field. The moto run prints Glue table glue_it.hive_table is not an Iceberg table: it has no \metadata_location` parameter`. Please drop the parenthetical.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep. glue_metadata_location only prints table_type when it's in the table's Parameters, which a Hive table normally doesn't carry, so the common case is exactly what the moto run prints. Dropped the parenthetical (2aa8808).

match failure {
SdkFailure::NotFound => IcebergError::TableNotFound(format!("{what} not found: {detail}")),
// `load_table` renames `table` to the table identifier (`name_denied_table`).
SdkFailure::AccessDenied => IcebergError::CatalogAccessDenied {

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.

Minor: detail is the full SDK chain, and on the server it reaches query clients verbatim in the 403. A Glue AccessDenied message usually includes User: arn:aws:sts::<account>:assumed-role/<role>/… is not authorized to perform glue:GetTable on arn:aws:glue:…, so any querying client learns the server's role ARN and account id. StorageAccessDenied already behaves this way, so this isn't new. Worth considering a shorter message on the query path and the full chain only in logs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed it was worth doing now, and since StorageAccessDenied has the same leak I fixed it at the query-path lifter rather than in the SDK client, so it covers the whole class (0e1c06c). storage_query_error now runs both StorageAccessDenied and CatalogAccessDenied through query_safe_denial, which swaps each arn:aws… token (any partition) for arn:<redacted>, keeps AWS's reason ("…is not authorized to perform: glue:GetTable … because no identity-based policy allows…"), and logs the full text at warn. That covers every catalog mode (REST, Glue, S3 Tables) and storage, and Delta's Unity denial goes through the same helper.

I went with redacting the identity rather than a shorter message, since the reason is the part whoever's debugging the query actually needs, but happy to go terser if you'd rather. The onboarding / verify path (storage_api_error) deliberately keeps the full text: it's admin-facing, and solo classifies verify failures by that wording, so redacting there would've been a solo-visible change. query_denials_redact_aws_identities_but_keep_the_reason pins both halves, and errors.md documents it.

ty("ex:Row"),
)
.await,
Err("Table not found"),

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.

Small tightening: "Table not found" would also match a not-found from another lane. Asserting "Glue table glue_it.no_such_table not found", which only the Glue client produces, pins that the error came from GetTable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tightened to Glue table glue_it.no_such_table not found (c188806). The new S3 Tables missing-table check asserts S3 Tables table glue_it.no_such_table not found the same way; changing that wording in the client fails it.

meta.catalog_uri = Some(cfg.catalog.catalog_label().to_string());
}
}
let id = cfg.table.identifier();

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.

Minor: for a mapping-defined source, cfg.table is the default.default placeholder (config.rs), so /info lists a phantom default.default table and each /info makes a GetTable / loadTable call for it that always fails (logged at debug). This already happened for REST via CLI/server. It now also reaches Glue, S3 Tables and Python REST sources. Skipping the placeholder here would fix it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 1cf4520. The placeholder is one named constant now (fluree_db_iceberg::config::MAPPING_DEFINED_TABLE), which the mode parser records and /info skips for a mapped source, so no phantom row and no doomed GetTable / loadTable on every /info. The moto test's /info check now asserts tables == ["glue_it.customers"], which fails if the skip is removed.

mapping: R2rmlMappingInput::Content(common.mapping),
mapping_media_type: None,
};
let rest = spec.catalog_uri.is_some();

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.

Minor: warehouse, auth and vended_credentials are applied only in REST mode, so passing them with glue= / s3_tables= is silently ignored. The CLI and server ignore the matching flags the same way. Raising an error (or at least warning) when they're set for a non-REST mode would save someone wondering why their auth did nothing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, and since the CLI and server dropped the same settings silently, I fixed it in the shared mode parser rather than in Python alone (fea526c). CatalogModeArgs now carries the REST-only settings a surface was given (rest_only), and from_mode refuses them in direct / glue / s3tables with <setting> applies to rest mode only; glue mode would ignore it, the setting spelled the way that surface spells it (--auth-bearer, auth_bearer, auth). That covers the CLI's bearer / OAuth2 / --warehouse flags, both server request shapes (Google metadata auth too, on the map route), and Python's warehouse / auth / vended_credentials.

For Python I made vended_credentials default to None so only an explicit True is refused: False agrees with every mode (and --no-vended-credentials on the CLI stays accepted for the same reason). Each surface builds its own list, so each surface's test drives every one of its settings through (88279cf); a field dropped from a list fails it.

This is a behavior change (an error where we used to silently ignore), so flagging it, but I went with an error over a warning since there's no case where the ignored setting does anything.

Comment thread fluree-db-iceberg/src/config.rs Outdated
@@ -184,6 +184,36 @@ impl IcebergGsConfig {
}

/// Validate the configuration.

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.

Nit: /// Validate the configuration. now sits on top of validate_aws_sdk_catalog, so pub fn validate below has no doc comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved back onto pub fn validate (126b248), thanks.

Comment thread fluree-db-iceberg/src/catalog/mod.rs Outdated
use async_trait::async_trait;
use std::collections::HashMap;

/// Response from loading a table, including optional vended credentials.

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.

Nit: same thing here. /// Response from loading a table… now documents name_denied_table instead of LoadTableResponse.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same fix, back on LoadTableResponse (126b248).

aaj3f added 3 commits October 8, 2026 20:09
The Glue/S3 Tables helpers were inserted between `LoadTableResponse` and
`IcebergGsConfig::validate` and their doc comments, so each comment had
merged into the new helper's. Each is back on its own item.
A rest/glue/s3tables source whose tables all come from its R2RML mapping
records `default.default` as its own table, to satisfy the
`namespace.table` shape. `/info` listed it (and asked the catalog about
it) next to the mapping's real tables. The placeholder is now named once,
`fluree_db_iceberg::config::MAPPING_DEFINED_TABLE`, and `/info` skips it
for a mapped source.
…n settings

When a REST loadTable reply carried a matching `storage-credentials` entry,
the entry's config replaced the reply's top-level `config` wholesale, so
the table's region, endpoint and path-style settings were lost and reads
went to the default endpoint. The entry now layers over the top-level map:
connection settings come from `config` unless the entry overrides them,
and credential keys come only from the entry (a remote-signing entry still
yields no credentials, so §2 refuses rather than reusing top-level keys
the catalog did not scope to this table).
aaj3f added 6 commits October 8, 2026 20:09
Glue reports an expired session, an unknown access key or a bad signature
as HTTP 400 error codes (`ExpiredTokenException`,
`UnrecognizedClientException`, `InvalidSignatureException`), so they fell
through to a generic catalog error. They are refusals of the caller's
identity, so they now classify as `CatalogAccessDenied`
(err:catalog/AccessDenied, 403), the same as `AccessDeniedException`.
…urce config

The cross-query loadTable cache (60s) and the disk pointer (300s, across
processes) were keyed by graph-source id + namespace + table only. Neither
is invalidated on drop, so a source dropped and re-created under the same
name against another catalog (URI, region, Glue catalog id, S3 Tables
bucket) could read the old catalog's table until the entry expired. Both
now key on the source config's fingerprint as well; the per-query session
pin stays on the bare key, since one query sees one config.
AWS phrases a denial as `User: arn:aws:sts::<account>:assumed-role/<role>/...
is not authorized to perform: ... because ...`. The query path passed that
text straight into err:catalog/AccessDenied and err:storage/AccessDenied,
so any client able to query a source learned the server's role and
account. On the query path (Iceberg storage and catalog denials for every
catalog mode, and Delta's Unity denial) ARNs are now replaced with
`arn:<redacted>`, the reason is kept, and the full text is logged.

The onboarding and verify path (`storage_api_error`) is unchanged: it is
admin-facing, and hosts classify verify failures by its text.
A REST catalog's auth (bearer, OAuth2 and, on the server, Google metadata
auth), its warehouse, and a request for vended credentials mean nothing to
direct, glue or s3tables mode, which dropped them silently: a user who
passed `--auth-bearer` with `--mode glue` got a source that ignored it.
The shared mode parser (`CatalogModeArgs::rest_only`) now refuses them
with `<setting> applies to rest mode only; <mode> mode would ignore it`,
on every surface: the CLI's flags, both server request shapes, and Python's
`map_iceberg` (whose `vended_credentials` now defaults to None so that
turning vending off, which agrees with every mode, is still accepted).
The moto CI test covered Glue only, so the s3tables mode had no test that
ran in CI. moto mocks S3 Tables too: the test now creates a table bucket,
namespace and table there, copies the fixture's customers metadata into the
table's warehouse bucket, points the table at it with
UpdateTableMetadataLocation, and reads it through the engine's own
GetTableMetadataLocation (50 rows), checks a missing table's error, browses
the bucket, and checks `/info` lists the mapping's table and not the
mapping-defined placeholder. The Glue missing-table check now asserts the
`Glue table ... not found` wording rather than any error.
…ml does

- The disk pointer's `FLUREE_ICEBERG_LOADTABLE_PTR_TTL_SECS` (300 s) was
  undocumented, and the freshness note named the 60 s in-memory TTL as the
  only freshness knob. Both are listed, with what each window means for a
  dropped table or revoked catalog access, and for Glue and S3 Tables,
  which are not asked again for the whole disk window.
- Omitting `r2rml` registers a plain Iceberg source; it does not
  auto-generate a mapping.
- The Glue not-an-Iceberg-table error no longer quotes a `table_type` it
  does not print.
@aaj3f aaj3f added area:iceberg Iceberg catalogs/credentials, R2RML, virtual datasets, materialize enhancement New feature or request labels Oct 9, 2026
aaj3f added 2 commits October 8, 2026 20:36
moto does not refuse a call, so the moto CI test cannot show how a real
denial is classified. A wiremock endpoint now answers the SDK clients with
AWS's own error shapes: Glue's HTTP 400 codes (`AccessDeniedException`
with the service's `:http://...` suffix, and the expired / unknown /
badly-signed credential codes) and S3 Tables' 403 `ForbiddenException` /
`AccessDeniedException` must reach `load_table`'s caller as
`CatalogAccessDenied` naming the table; Glue's
`EntityNotFoundException` and S3 Tables' 404 `NotFoundException` as
`TableNotFound`.
The server and Python tests refused one REST-only setting each, so a field
dropped from a surface's list would go unnoticed (each surface builds its
own list from its own request shape). The server test now sends every field
on both request shapes (the map route's eleven, Google metadata auth
included, and the browse/preview connection's nine); Python's covers
`warehouse` and the `s3_tables=` arm too. The CLI's already drives all
nine flags.
@aaj3f

aaj3f commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the careful second pass, @bplatz! I agreed with all of it, so it's all folded in here rather than filed: pushed as fast-forwards e8486de49..88279cf0f, with replies on each inline thread. On the two that don't anchor to a line:

  • S3 Tables now runs in CI. moto 5.2.3 does mock s3tables, so it_iceberg_glue_moto now creates a table bucket, namespace and table there, copies the fixture's customers metadata into the table's moto-managed warehouse bucket, points the table at it with UpdateTableMetadataLocation, and then reads it through the engine's own GetTableMetadataLocation (50 rows), checks a missing table's error, and browses the bucket (c188806); the Glue source's /info check now asserts its table list too. moto never refuses a call, though, so for the AccessDenied half there's also a wiremock test (cafe48c) that serves the real error shapes to both SDK clients (Glue's 400 codes, S3 Tables' 403 / 404) and checks they come out typed. Two moto quirks, if anyone extends the seed: its GetTable reply doesn't deserialize in the Rust SDK, so the seed takes the version token and warehouse location from GetTableMetadataLocation instead; and UpdateTableMetadataLocation returns a 200 whose body the SDK can't parse, so the seed accepts the success status, and the engine's own read of the pointer is what proves the update took.
  • Labels: added area:iceberg and enhancement.

Two of the fixes went a bit broader than the comment they answer, so flagging them in case you'd rather they be narrower: the ARN redaction covers every query-path denial (all catalog modes, storage, and Delta's Unity denial), not just the Glue catalog message; and the REST-only refusal is on every surface, so --mode glue --auth-bearer … is now an error rather than a silent no-op.

Verification, fwiw: fmt + clippy -D warnings on the five touched crates; the iceberg / api / server / CLI unit suites and the api Iceberg integration suites; Python pytest, mypy and sphinx -n -W; it_iceberg_glue_moto 16/16 against a fresh moto, twice; and scripts/glue-local/check.sh target against the rebuilt CLI, 0 failures with the counts unchanged. Every new Rust test was mutation-checked: revert the fix it pins and it fails.

@aaj3f
aaj3f merged commit 21eddb9 into main Oct 9, 2026
19 checks passed
@aaj3f
aaj3f deleted the feat/iceberg-glue-sigv4 branch October 9, 2026 01:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:iceberg Iceberg catalogs/credentials, R2RML, virtual datasets, materialize enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants