eric-maynard opened a new pull request, #243:
URL: https://github.com/apache/polaris/pull/243
# Description
In the event that the persistence layer fails due to a primary key conflict,
we should translate this to an AlreadyExistException which maps to response
409. Currently, we are returning a 500.
Fixes #226
## Type of change
Please delete options that are not relevant.
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] Documentation update
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update
# How Has This Been Tested?
As we don't have a robust test setup for eclipselink-backed Polaris
currently, I manually tested with the following setup:
```
<property name="jakarta.persistence.jdbc.url"
value="jdbc:postgresql://localhost:5432/db"/>
<property name="jakarta.persistence.jdbc.user" value="polaris"/>
<property name="jakarta.persistence.jdbc.password" value="test"/>
<property name="jakarta.persistence.schema-generation.database.action"
value="create"/>
<property name="eclipselink.logging.level.sql" value="FINE"/>
<property name="eclipselink.logging.parameters" value="true"/>
<property name="eclipselink.persistence-context.flush-mode"
value="auto"/>
```
I then created a duplicate grant:
```
./polaris \
--access-token 'principal:root;realm:default-realm' \
catalogs \
create example_catalog \
--storage-type file \
--default-base-location 'file:///tmp/example'
./polaris \
--access-token 'principal:root;realm:default-realm' \
principals \
create \
example_user
./polaris \
--access-token 'principal:root;realm:default-realm' \
principal-roles \
create \
example_user_role
./polaris \
--access-token 'principal:root;realm:default-realm' \
principal-roles \
grant \
--principal example_user \
example_user_role
./polaris \
--access-token 'principal:root;realm:default-realm' \
principal-roles \
grant \
--principal example_user \
example_user_role
```
This PR fixes the 500 and causes Polaris to return a 409:
```
./polaris \
> --access-token 'principal:root;realm:default-realm' \
> principal-roles \
> grant \
> --principal example_user \
> example_user_role
Exception when communicating with the Polaris server.
AlreadyExistsException: Grant already exists
```
# Checklist:
Please delete options that are not relevant.
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] My changes generate no new warnings
--
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]