You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@polaris.apache.org by "youngrae81 (via GitHub)" <gi...@apache.org> on 2026/09/21 11:41:54 UTC
[I] Detaching a policy from a target it is not attached to returns HTTP 500 instead of 404 [polaris]
youngrae81 opened a new issue, #5567:
URL: https://github.com/apache/polaris/issues/5567
### Describe the bug
Describe the bug
`POST /polaris/v1/{prefix}/namespaces/{ns}/policies/{policy}/mappings` (detach) fails with `500 Internal Server Error` when the policy and the target both exist but the policy was never attached to that target.
The metastore already reports this case with a dedicated status: `detachPolicyFromEntity` returns `POLICY_MAPPING_NOT_FOUND` (documented in `PolarisPolicyMappingManager`, implemented in `AtomicOperationMetaStoreManager` and `TransactionalMetaStoreManagerImpl`). `PolicyCatalog.detachPolicy` does not look at the status and throws `IllegalStateException` for any failure, which the exception mapper turns into a 500. `attachPolicy` in the same class maps its analogous status (`POLICY_MAPPING_OF_SAME_TYPE_ALREADY_EXISTS`) to 409, so only the detach side is missing.
The policy API spec lists this case under the 404 response of the detach operation (`NoSuchMappingException`, example `MappingToUnsetDoesNotExist`: "The given mapping between policy and target does not exist").
Related: the NoSQL metastore returns success for the same request (nothing is removed, but no error is reported), so the three backends disagree with each other and with the `PolarisPolicyMappingManager` contract.
### To Reproduce
1. Create a namespace `ns1` and a policy `p1` in it (any type).
2. Without attaching it, detach it from the namespace:
```
curl -i -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
"http://localhost:8181/api/catalog/polaris/v1/<catalog>/namespaces/ns1/policies/p1/mappings" \
-d '{"target":{"type":"namespace","path":["ns1"]}}'
```
### Actual Behavior
HTTP 500. Server log:
IllegalStateException: Failed to detach policy PolicyIdentifier[namespace=ns1, name=p1] from <catalog>.ns1 error status: POLICY_MAPPING_NOT_FOUND with extraInfo: null (relational-jdbc and in-memory backends). NoSQL backend: HTTP 204 although nothing was detached.
### Expected Behavior
HTTP 404 on every backend:
`{"error":{"type":"NoSuchMappingException","message":"The given mapping between policy ... does not exist","code":404}}`
### Additional context
Fix and tests are ready; PR to follow. Not a duplicate of #1582 (asks for more error-path tests in general) and unrelated to #5311 / #5557 (list pagination).
### System information
Polaris main @ 7641e19121 (1.8.0-SNAPSHOT), Iceberg 1.11.0. Reproduced on relational-jdbc (H2) and NoSQL in-memory backends.
--
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: issues-unsubscribe@polaris.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Detaching a policy from a target it is not attached to returns HTTP 500 instead of 404 [polaris]
Posted by "flyrain (via GitHub)" <gi...@apache.org>.
flyrain closed issue #5567: Detaching a policy from a target it is not attached to returns HTTP 500 instead of 404
URL: https://github.com/apache/polaris/issues/5567
--
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: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org