From 095eeeb4d43ea94955145547e422b82029a43351 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 14 Jun 2026 17:58:45 +0200 Subject: [PATCH] fix(tag): warn when a tag's root cannot be resolved MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit resolveRoot silently falls back to returning the tag itself when no null-parent ancestor surfaces — an orphaned parent_id or a chain deeper than the findAncestorIds CTE depth guard. The chip then renders a non-root tag as if it were the theme, with no trace. Log a warning (UUIDs only, per REQ-014) before the fallback so the anomaly is diagnosable. Co-Authored-By: Claude Opus 4.8 --- .../main/java/org/raddatz/familienarchiv/tag/TagService.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/src/main/java/org/raddatz/familienarchiv/tag/TagService.java b/backend/src/main/java/org/raddatz/familienarchiv/tag/TagService.java index 23bb2cb5..e6a5dfa8 100644 --- a/backend/src/main/java/org/raddatz/familienarchiv/tag/TagService.java +++ b/backend/src/main/java/org/raddatz/familienarchiv/tag/TagService.java @@ -220,6 +220,11 @@ public class TagService { if (ancestor != null && ancestor.getParentId() == null) return ancestor; } } + // No null-parent ancestor surfaced — the parent is orphaned or the chain is deeper than the + // findAncestorIds CTE's depth guard. Fall back to the tag as its own root, but surface it: + // a silently mislabeled root would otherwise be invisible. UUIDs only (no tag names logged). + log.warn("Tag {} has parent {} but no root surfaced from its ancestry; " + + "treating it as its own root.", tag.getId(), tag.getParentId()); return tag; }