Skip to content

Core, Open-API: Add server-side warehouse validation for /v1/config endpoint - #16247

Closed
kevinjqliu wants to merge 7 commits into
apache:mainfrom
kevinjqliu:kevinjqliu/config-404-server
Closed

kevinjqliu wants to merge 7 commits into
apache:mainfrom
kevinjqliu:kevinjqliu/config-404-server

Conversation

@kevinjqliu

@kevinjqliu kevinjqliu commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds server-side warehouse validation to the REST catalog test fixture server, complementing the client-side changes in #16059.

When a warehouse query parameter is provided to /v1/config that doesn't match the configured warehouse, the server returns a 404 NoSuchWarehouseException.

Testing

Build and run the REST catalog server locally:

Default (without setting catalog.name)

Preserves old behavior, everything returns 200. Internally the default catalog name is rest_backend. We are explicitly not gating on that to be backwards compatible

./gradlew :iceberg-open-api:shadowJar -x test
java -jar open-api/build/libs/iceberg-open-api-test-fixtures-runtime-1.12.0-SNAPSHOT.jar

With setting catalog.name

./gradlew :iceberg-open-api:shadowJar -x test
CATALOG_CATALOG_NAME=mywarehouse java -jar open-api/build/libs/iceberg-open-api-test-fixtures-runtime-1.12.0-SNAPSHOT.jar

kevinjqliu and others added 2 commits May 7, 2026 13:46
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
@kevinjqliu
kevinjqliu marked this pull request as draft May 8, 2026 16:46
kevinjqliu and others added 4 commits May 8, 2026 09:55
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
@kevinjqliu

Copy link
Copy Markdown
Contributor Author

@gaborkaszab you've been in this part of the codebase, could you take a look?

@kevinjqliu
kevinjqliu marked this pull request as ready for review May 8, 2026 17:42

@gaborkaszab gaborkaszab 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 PR, @kevinjqliu !
I took a quick look and suggested some alternative ways to do this. Let me know what you think!
Now that we have both the client and server side of this, would be nice to see some tests in TestRESTCatalog for mismatching warehouse names and/or locations.

@@ -31,6 +31,7 @@ private RESTCatalogProperties() {}
public static final String SNAPSHOT_LOADING_MODE = "snapshot-loading-mode";
public static final SnapshotMode SNAPSHOT_LOADING_MODE_DEFAULT = SnapshotMode.ALL;
public static final String SNAPSHOTS_QUERY_PARAMETER = "snapshots";

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.

RESTSessionCatalog uses CatalogProperties.WAREHOUSE_LOCATION for the query param name. I'd recommend using the same param both at the client and the server side. My preference would be to replace the one in RESTSessionCatalog.fetchConfig() to use this one.

Additionally, when we populate this param on the client side for the request, the code comments talks about warehouse location. I'm a bit confused. Isn't this param a warehouse name, or is it a warehouse location?

return castResponse(responseType, handleOAuthRequest(body));

case CONFIG:
if (vars.containsKey(RESTCatalogProperties.WAREHOUSE_QUERY_PARAMETER)) {

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: to keep this as simple as possible, can we simply do this and return early if the warehouse is null?

validateWarehouse(vars.get(RESTCatalogProperties.WAREHOUSE_QUERY_PARAMETER));


/** Validates that the given warehouse exists. Subclasses may override. */
protected void validateWarehouse(String warehouse) {
// no-op: accept any warehouse by default

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 reason we leave the implementation to RESTServerCatalogAdapter is because it has the catalog configs that we need to check for equality with the warehouse query param, right?
This seems a bit odd to me. Can't we pass the catalog configs too to RESTCatalogAdapter? Maybe pass CatalogContext via a new constructor?
Other option could be what the applyCredentials does. It doesn't go through inheritance but we do the checks for response types and enhance with credentials if needed. If we have to keep the warehouse checks on this level of abstraction and not pass the catalog configs to RESTCatalogAdapter, we might want to do the same: check for ConfigResponse and validate the param in vars.
I'd personally go for the former option and pass RESTCatalogAdapter whatever is needed to perform the check itself.

@github-actions

Copy link
Copy Markdown

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.

@github-actions github-actions Bot added the stale label Jun 11, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been closed due to lack of activity. This is not a judgement on the merit of the PR in any way. It is just a way of keeping the PR queue manageable. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.

@github-actions github-actions Bot closed this Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants