fix(tag): resolve case-colliding tag names without throwing (#730) #733
@@ -68,7 +68,7 @@ public class TagService {
|
|||||||
if (exact.isPresent()) return exact.get(); // exact-case wins (edit round-trip replays the stored name)
|
if (exact.isPresent()) return exact.get(); // exact-case wins (edit round-trip replays the stored name)
|
||||||
List<Tag> caseInsensitive = tagRepository.findAllByNameIgnoreCase(cleanName);
|
List<Tag> caseInsensitive = tagRepository.findAllByNameIgnoreCase(cleanName);
|
||||||
if (!caseInsensitive.isEmpty()) {
|
if (!caseInsensitive.isEmpty()) {
|
||||||
return caseInsensitive.stream().min(Comparator.comparing(Tag::getId)).get(); // deterministic tie-break by id — never throw
|
return caseInsensitive.stream().min(Comparator.comparing(Tag::getId)).orElseThrow(); // deterministic tie-break by id — list is non-empty, never throws
|
||||||
}
|
}
|
||||||
return tagRepository.save(Tag.builder().name(cleanName).build()); // create-when-absent (orphan tag: null sourceRef/parentId)
|
return tagRepository.save(Tag.builder().name(cleanName).build()); // create-when-absent (orphan tag: null sourceRef/parentId)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user