justinmclean opened a new issue, #10221:
URL: https://github.com/apache/gravitino/issues/10221
### What would you like to be improved?
getTagIdByTagName(Long metalakeId, String tagName) calls
selectTagMetaByMetalakeIdAndName(...) and immediately dereferences .getTagId().
When the tag is missing, the mapper can return null, causing a
NullPointerException instead of a domain-level “not found” exception. This is
reachable via TAG ID resolution paths and can surface in production for missing
or concurrently deleted tags.
### How should we improve?
Add a null check in getTagIdByTagName: store the mapper result in a local
TagPO, and if it is null, throw NoSuchEntityException for tagName. This keeps
behavior consistent with other meta services (role/user/group).
Here's a test to help:
```
@TestTemplate
public void testGetTagIdByTagNameWhenTagNotFound() throws IOException {
createAndInsertMakeLake(METALAKE_NAME);
TagMetaService tagMetaService = TagMetaService.getInstance();
long metalakeId =
MetalakeMetaService.getInstance().getMetalakeIdByName(METALAKE_NAME);
Assertions.assertThrows(
NoSuchEntityException.class,
() -> tagMetaService.getTagIdByTagName(metalakeId, "missing_tag"));
}
```
--
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]