aakashofficial-k01 opened a new issue, #4363:
URL: https://github.com/apache/amoro/issues/4363
### What happened?
In `RestCatalogService.java`, the `head(...)` route is registered for tables
(`tableExists`), but was omitted for namespaces:
```java
// Tables have HEAD registered:
head("/v1/catalogs/{catalog}/namespaces/{namespace}/tables/{table}",
this::tableExists);
// Namespaces only have GET, POST, DELETE:
get("/v1/catalogs/{catalog}/namespaces/{namespace}", this::getNamespace);
delete("/v1/catalogs/{catalog}/namespaces/{namespace}", this::dropNamespace);
```
When clients issue `HEAD /v1/{prefix}/namespaces/{namespace}`:
1. Javalin router finds no matching route.
2. The request falls through to Jetty's static file handler, returning `HTTP
200 OK` (0 bytes).
3. Modern, spec-compliant Iceberg REST clients (such as Apache's official
`iceberg-go` client via `cat.CheckNamespaceExists`) interpret `HTTP 200 OK` as
existence, incorrectly concluding that any non-existent database exists
(`Exists: true`).
**Expected Behavior:**
Per the Iceberg REST Catalog OpenAPI specification (`operationId:
namespaceExists`):
- `HEAD /v1/{prefix}/namespaces/{namespace}` should return `204 No Content`
if the namespace exists.
- It should return `404 Not Found` if the namespace does not exist.
### Affects Versions
master, 0.8.x, 0.9.x
### What table formats are you seeing the problem on?
- Iceberg
### What engines are you seeing the problem on?
- AMS
### How to reproduce
Run:
```bash
curl -i -X HEAD
http://<ams-host>:1630/api/iceberg/rest/v1/catalogs/<catalog>/namespaces/non_existent_db
```
**Actual:**
`HTTP/1.1 200 OK`
**Expected:**
`HTTP/1.1 404 Not Found`
### Relevant log output
```text
=== Testing Existing Namespace 'test_db' ===
[HTTP-GO] HEAD
http://amoro:1630/api/iceberg/rest/v1/catalogs/lakehouse/namespaces/test_db
[HTTP-GO] -> 200 200 OK
CheckNamespaceExists('test_db') -> Exists: true, Err: <nil>
=== Testing Non-Existent Namespace 'non_existent_db' ===
[HTTP-GO] HEAD
http://amoro:1630/api/iceberg/rest/v1/catalogs/lakehouse/namespaces/non_existent_db
[HTTP-GO] -> 200 200 OK
CheckNamespaceExists('non_existent_db') -> Exists: true, Err: <nil>
```
### Are you willing to submit a PR?
- [x] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's Code of Conduct
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]