justinmclean opened a new issue, #10659:
URL: https://github.com/apache/gravitino/issues/10659
### What would you like to be improved?
When changing a tag name to one that already exists in the same metalake,
the server returns an internal error instead of an already exists response.
Observed code path
- TagManager.java (line 175) catches EntityAlreadyExistsException during
alterTag(...) and wraps it in a generic RuntimeException.
- ExceptionHandlers.java (line 718) only maps TagAlreadyExistsException to
an already-exists response.
- Generic RuntimeException falls through to internal error handling in
ExceptionHandlers.java (line 1044).
Impact
A valid user mistake, renaming a tag to an existing tag name, is surfaced as
HTTP 500. Clients then receive a generic runtime failure instead of a
domain-specific conflict like TagAlreadyExistsException.
### How should we improve?
In TagManager.alterTag(...), convert EntityAlreadyExistsException to
TagAlreadyExistsException, similar to createTag(...), for example:
```
} catch (EntityAlreadyExistsException e) {
throw new TagAlreadyExistsException(
e, "Tag with name %s under metalake %s already exists", newName,
metalake);
}
```
Here's a unit test to help:
```
@Test
public void testAlterTagRenameToExistingTag() {
tagManager.createTag(METALAKE, "tag1", null, null);
tagManager.createTag(METALAKE, "tag2", null, null);
TagAlreadyExistsException exception =
Assertions.assertThrows(
TagAlreadyExistsException.class,
() -> tagManager.alterTag(METALAKE, "tag1",
TagChange.rename("tag2")));
Assertions.assertEquals(
"Tag with name tag2 under metalake metalake_for_tag_test already
exists",
exception.getMessage());
Assertions.assertEquals("tag1", tagManager.getTag(METALAKE,
"tag1").name());
Assertions.assertEquals("tag2", tagManager.getTag(METALAKE,
"tag2").name());
}
```
--
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]