aakashofficial-k01 opened a new pull request, #4364:
URL: https://github.com/apache/amoro/pull/4364

   ## Why are the changes needed?
   
   Close #4363.
   
   In `RestCatalogService.java`, the `head(...)` route is registered for tables 
(`tableExists`), but was omitted for namespaces. Consequently, unrouted `HEAD` 
requests to `/v1/catalogs/{catalog}/namespaces/{namespace}` fell through to 
Jetty's static file handler, returning `HTTP 200 OK` (0 bytes).
   
   Modern, spec-compliant Iceberg REST clients (such as Apache's official 
`github.com/apache/iceberg-go` client via `cat.CheckNamespaceExists`) strictly 
issue `HEAD /v1/{prefix}/namespaces/{namespace}` for namespace existence checks 
without fallback to `GET`. As a result, `iceberg-go` incorrectly reported that 
any non-existent database existed (`Exists: true`).
   
   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.
   
   ## Brief change log
   
   - **`RestCatalogService.java`**:
     - Registered `head("/v1/catalogs/{catalog}/namespaces/{namespace}", 
this::namespaceExists)` in `endpoints()`.
     - Added `namespaceExists` handler delegating to `handleNamespace(ctx, 
(catalog, database) -> null)`. When the namespace exists, `null` is translated 
by `handleCatalog` to `204 No Content`. When it does not exist, 
`NoSuchNamespaceException` is thrown and mapped to `404 Not Found`.
   - **`TestInternalIcebergCatalogService.java`**:
     - Added `testNamespaceExists()` validating the full HTTP `HEAD` lifecycle: 
`404` (before creation) -> `204` (after creation) -> `404` (after drop).
   
   ## How was this patch tested?
   
   - [x] Added unit test 
`TestInternalIcebergCatalogService.NamespaceTests#testNamespaceExists` covering 
negative, positive, and drop lifecycles.
   - [x] Verified against live `iceberg-go` client 
(`github.com/apache/iceberg-go v0.6.0`) in Docker:
     - `CheckNamespaceExists('test_db')` -> `204 No Content` (`Exists: true`)
     - `CheckNamespaceExists('non_existent_db')` -> `404 Not Found` (`Exists: 
false`)
   - [x] Executed `./mvnw spotless:check checkstyle:check -pl amoro-ams` (0 
violations).
   
   ## Documentation
   
   - Does this pull request introduce a new feature? no
   


-- 
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]

Reply via email to