fix(entity): secondary NPE + logic bug in ColumnEntityUpdater.updateColumns

Copilot review caught two pre-existing bugs in the same method this PR
already touches:

1. NPE on added column tags. `added.getTags().stream()` NPEs when a
   column has no tags (Column schema defaults tags to null). Wrap with
   listOrEmpty(added.getTags()) so the stream is safe.

2. Inverted carry-forward condition. The original
       if (nullOrEmpty(addedColumn.getTags()) && nullOrEmpty(deleted.getTags()))
           addedColumn.setTags(deleted.getTags());
   only copied when BOTH sides were empty — a no-op. The intent is "if
   the added column has no tags but the deleted column did, preserve
   them". Flip to !nullOrEmpty(deleted.getTags()).

Both fit the scope of this PR (null-safety in updateColumns) so
including them rather than spinning a separate PR.
This commit is contained in:
sonika-shah 2026-05-13 18:25:04 +05:30
parent 84a124f11a
commit 4a9a639bab

View file

@ -8763,7 +8763,7 @@ public abstract class EntityRepository<T extends EntityInterface> {
if (nullOrEmpty(addedColumn.getDescription())) {
addedColumn.setDescription(deleted.getDescription());
}
if (nullOrEmpty(addedColumn.getTags()) && nullOrEmpty(deleted.getTags())) {
if (nullOrEmpty(addedColumn.getTags()) && !nullOrEmpty(deleted.getTags())) {
addedColumn.setTags(deleted.getTags());
}
}
@ -8780,7 +8780,9 @@ public abstract class EntityRepository<T extends EntityInterface> {
// Add tags related to newly added columns
for (Column added : addedColumns) {
applyTagsAddInFlushAndDeferRdf(
added.getTags().stream().map(tag -> tag.withAppliedBy(updatingUser.getName())).toList(),
listOrEmpty(added.getTags()).stream()
.map(tag -> tag.withAppliedBy(updatingUser.getName()))
.toList(),
added.getFullyQualifiedName());
}