Skip to content
5 changes: 3 additions & 2 deletions crates/catalog/glue/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ use async_trait::async_trait;
use aws_sdk_glue::operation::create_table::CreateTableError;
use aws_sdk_glue::operation::update_table::UpdateTableError;
use aws_sdk_glue::types::TableInput;
use iceberg::io::{
FileIO, S3_ACCESS_KEY_ID, S3_ENDPOINT, S3_REGION, S3_SECRET_ACCESS_KEY, S3_SESSION_TOKEN,
use iceberg::io::FileIO;
use iceberg::io::storage::config::{
S3_ACCESS_KEY_ID, S3_ENDPOINT, S3_REGION, S3_SECRET_ACCESS_KEY, S3_SESSION_TOKEN,
};
use iceberg::spec::{TableMetadata, TableMetadataBuilder};
use iceberg::table::Table;
Expand Down
4 changes: 3 additions & 1 deletion crates/catalog/glue/tests/glue_catalog_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@

use std::collections::HashMap;

use iceberg::io::{S3_ACCESS_KEY_ID, S3_ENDPOINT, S3_REGION, S3_SECRET_ACCESS_KEY};
use iceberg::io::storage::config::{
S3_ACCESS_KEY_ID, S3_ENDPOINT, S3_REGION, S3_SECRET_ACCESS_KEY,
};
use iceberg::spec::{NestedField, PrimitiveType, Schema, Type};
use iceberg::transaction::{ApplyTransactionAction, Transaction};
use iceberg::{
Expand Down
4 changes: 3 additions & 1 deletion crates/catalog/hms/tests/hms_catalog_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@

use std::collections::HashMap;

use iceberg::io::{S3_ACCESS_KEY_ID, S3_ENDPOINT, S3_REGION, S3_SECRET_ACCESS_KEY};
use iceberg::io::storage::config::{
S3_ACCESS_KEY_ID, S3_ENDPOINT, S3_REGION, S3_SECRET_ACCESS_KEY,
};
use iceberg::spec::{NestedField, PrimitiveType, Schema, Type};
use iceberg::{Catalog, CatalogBuilder, Namespace, NamespaceIdent, TableCreation, TableIdent};
use iceberg_catalog_hms::{
Expand Down
115 changes: 100 additions & 15 deletions crates/catalog/rest/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ use crate::types::{
pub const REST_CATALOG_PROP_URI: &str = "uri";
/// REST catalog warehouse location
pub const REST_CATALOG_PROP_WAREHOUSE: &str = "warehouse";
/// Disable header redaction in error logs (defaults to false for security)
pub const REST_CATALOG_PROP_DISABLE_HEADER_REDACTION: &str = "disable-header-redaction";

const ICEBERG_REST_SPEC_VERSION: &str = "0.14.1";
const CARGO_PKG_VERSION: &str = env!("CARGO_PKG_VERSION");
Expand Down Expand Up @@ -330,6 +332,17 @@ impl RestCatalogConfig {
params
}

/// Check if header redaction is disabled in error logs.
///
/// Returns true if the `disable-header-redaction` property is set to "true".
/// Defaults to false for security (headers are redacted by default).
pub(crate) fn disable_header_redaction(&self) -> bool {
self.props
.get(REST_CATALOG_PROP_DISABLE_HEADER_REDACTION)
.map(|v| v.eq_ignore_ascii_case("true"))
.unwrap_or(false)
}

/// Merge the `RestCatalogConfig` with the a [`CatalogConfig`] (fetched from the REST server).
pub(crate) fn merge_with_config(mut self, mut config: CatalogConfig) -> Self {
if let Some(uri) = config.overrides.remove("uri") {
Expand Down Expand Up @@ -430,7 +443,11 @@ impl RestCatalog {

match http_response.status() {
StatusCode::OK => deserialize_catalog_response(http_response).await,
_ => Err(deserialize_unexpected_catalog_error(http_response).await),
_ => Err(deserialize_unexpected_catalog_error(
http_response,
client.disable_header_redaction(),
)
.await),
}
}

Expand Down Expand Up @@ -534,7 +551,13 @@ impl RestCatalog {
"Tried to load a table that does not exist",
));
}
_ => return Err(deserialize_unexpected_catalog_error(http_response).await),
_ => {
return Err(deserialize_unexpected_catalog_error(
http_response,
context.client.disable_header_redaction(),
)
.await);
}
};

// Build config with proper precedence, with each next config overriding previous one:
Expand Down Expand Up @@ -634,7 +657,11 @@ impl RestCatalog {
ErrorKind::Unexpected,
"Tried to load credentials for a table that does not exist",
)),
_ => Err(deserialize_unexpected_catalog_error(http_response).await),
_ => Err(deserialize_unexpected_catalog_error(
http_response,
context.client.disable_header_redaction(),
)
.await),
}
}

Expand Down Expand Up @@ -694,7 +721,13 @@ impl Catalog for RestCatalog {
"The parent parameter of the namespace provided does not exist",
));
}
_ => return Err(deserialize_unexpected_catalog_error(http_response).await),
_ => {
return Err(deserialize_unexpected_catalog_error(
http_response,
context.client.disable_header_redaction(),
)
.await);
}
}
}

Expand Down Expand Up @@ -729,7 +762,11 @@ impl Catalog for RestCatalog {
ErrorKind::Unexpected,
"Tried to create a namespace that already exists",
)),
_ => Err(deserialize_unexpected_catalog_error(http_response).await),
_ => Err(deserialize_unexpected_catalog_error(
http_response,
context.client.disable_header_redaction(),
)
.await),
}
}

Expand All @@ -753,7 +790,11 @@ impl Catalog for RestCatalog {
ErrorKind::Unexpected,
"Tried to get a namespace that does not exist",
)),
_ => Err(deserialize_unexpected_catalog_error(http_response).await),
_ => Err(deserialize_unexpected_catalog_error(
http_response,
context.client.disable_header_redaction(),
)
.await),
}
}

Expand All @@ -770,7 +811,11 @@ impl Catalog for RestCatalog {
match http_response.status() {
StatusCode::NO_CONTENT | StatusCode::OK => Ok(true),
StatusCode::NOT_FOUND => Ok(false),
_ => Err(deserialize_unexpected_catalog_error(http_response).await),
_ => Err(deserialize_unexpected_catalog_error(
http_response,
context.client.disable_header_redaction(),
)
.await),
}
}

Expand Down Expand Up @@ -801,7 +846,11 @@ impl Catalog for RestCatalog {
ErrorKind::Unexpected,
"Tried to drop a namespace that does not exist",
)),
_ => Err(deserialize_unexpected_catalog_error(http_response).await),
_ => Err(deserialize_unexpected_catalog_error(
http_response,
context.client.disable_header_redaction(),
)
.await),
}
}

Expand Down Expand Up @@ -838,7 +887,13 @@ impl Catalog for RestCatalog {
"Tried to list tables of a namespace that does not exist",
));
}
_ => return Err(deserialize_unexpected_catalog_error(http_response).await),
_ => {
return Err(deserialize_unexpected_catalog_error(
http_response,
context.client.disable_header_redaction(),
)
.await);
}
}
}

Expand Down Expand Up @@ -892,7 +947,13 @@ impl Catalog for RestCatalog {
"The table already exists",
));
}
_ => return Err(deserialize_unexpected_catalog_error(http_response).await),
_ => {
return Err(deserialize_unexpected_catalog_error(
http_response,
context.client.disable_header_redaction(),
)
.await);
}
};

let metadata_location = response.metadata_location.as_ref().ok_or(Error::new(
Expand Down Expand Up @@ -949,7 +1010,11 @@ impl Catalog for RestCatalog {
ErrorKind::Unexpected,
"Tried to drop a table that does not exist",
)),
_ => Err(deserialize_unexpected_catalog_error(http_response).await),
_ => Err(deserialize_unexpected_catalog_error(
http_response,
context.client.disable_header_redaction(),
)
.await),
}
}

Expand All @@ -967,7 +1032,11 @@ impl Catalog for RestCatalog {
match http_response.status() {
StatusCode::NO_CONTENT | StatusCode::OK => Ok(true),
StatusCode::NOT_FOUND => Ok(false),
_ => Err(deserialize_unexpected_catalog_error(http_response).await),
_ => Err(deserialize_unexpected_catalog_error(
http_response,
context.client.disable_header_redaction(),
)
.await),
}
}

Expand Down Expand Up @@ -996,7 +1065,11 @@ impl Catalog for RestCatalog {
ErrorKind::Unexpected,
"Tried to rename a table to a name that already exists",
)),
_ => Err(deserialize_unexpected_catalog_error(http_response).await),
_ => Err(deserialize_unexpected_catalog_error(
http_response,
context.client.disable_header_redaction(),
)
.await),
}
}

Expand Down Expand Up @@ -1040,7 +1113,13 @@ impl Catalog for RestCatalog {
"The given table already exists.",
));
}
_ => return Err(deserialize_unexpected_catalog_error(http_response).await),
_ => {
return Err(deserialize_unexpected_catalog_error(
http_response,
context.client.disable_header_redaction(),
)
.await);
}
};

let metadata_location = response.metadata_location.as_ref().ok_or(Error::new(
Expand Down Expand Up @@ -1112,7 +1191,13 @@ impl Catalog for RestCatalog {
"A server-side gateway timeout occurred; the commit state is unknown.",
));
}
_ => return Err(deserialize_unexpected_catalog_error(http_response).await),
_ => {
return Err(deserialize_unexpected_catalog_error(
http_response,
context.client.disable_header_redaction(),
)
.await);
}
};

// TODO: Support vended credentials here.
Expand Down
Loading
Loading