From 10dc92b45e2ecb08a146757b321aeb6a6af3525f Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Sun, 5 Apr 2026 20:50:40 -0400 Subject: [PATCH] Fix 'Mapping already exists' error on second save After createMapping, the new mapping's id was not stored in allValues state, so editing the row again fell into the create path instead of update. Now stores created.id so subsequent saves correctly use updateMapping. Co-Authored-By: Claude Sonnet 4.6 --- ui/src/pages/Mappings.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/src/pages/Mappings.jsx b/ui/src/pages/Mappings.jsx index c970bbf..d49f6fe 100644 --- a/ui/src/pages/Mappings.jsx +++ b/ui/src/pages/Mappings.jsx @@ -130,14 +130,14 @@ export default function Mappings({ source }) { valueKey(x.extracted_value) === k ? { ...x, output: updated.output } : x )) } else { - await api.createMapping({ + const created = await api.createMapping({ source_name: source, rule_name: row.rule_name, input_value: row.extracted_value, output }) setAllValues(av => av.map(x => - valueKey(x.extracted_value) === k ? { ...x, is_mapped: true, output } : x + valueKey(x.extracted_value) === k ? { ...x, is_mapped: true, mapping_id: created.id, output } : x )) } setDrafts(d => { const n = { ...d }; delete n[k]; return n })