File: internal/tool/knowledge_graph.go
Lines: 186
Severity: Medium
Problem
Line 186 unconditionally assigns ex.Tags = p.Tags when updating an existing node. If the caller didn't provide tags (p.Tags is nil from JSON unmarshal), existing tags are silently erased. In contrast, Status at line 187-189 is conditionally preserved with if p.Status != "". Tags get no such guard — inconsistent and surprising data loss.
Trigger Scenario
- Node exists with
tags: ["decision", "accepted"] and status: "accepted"
- User calls
knowledge_graph add with the same ID to update only the title (no tags, no status provided)
- After update:
tags becomes nil (erased), status remains "accepted" (preserved)
- Tags are silently destroyed while status survives
Expected vs Actual
- Expected: Tags are preserved when not provided, just like Status
- Actual: Tags are unconditionally overwritten with nil
Fix
Add a nil-guard for Tags, matching the Status pattern:
if p.Tags != nil {
ex.Tags = p.Tags
}
File:
internal/tool/knowledge_graph.goLines: 186
Severity: Medium
Problem
Line 186 unconditionally assigns
ex.Tags = p.Tagswhen updating an existing node. If the caller didn't provide tags (p.Tags is nil from JSON unmarshal), existing tags are silently erased. In contrast,Statusat line 187-189 is conditionally preserved withif p.Status != "". Tags get no such guard — inconsistent and surprising data loss.Trigger Scenario
tags: ["decision", "accepted"]andstatus: "accepted"knowledge_graph addwith the same ID to update only the title (no tags, no status provided)tagsbecomes nil (erased),statusremains "accepted" (preserved)Expected vs Actual
Fix
Add a nil-guard for Tags, matching the Status pattern: