fix(control-plane): clear mental-model tags when the edit field is emptied (#2507) - #2508
Merged
nicoloboschi merged 1 commit intoJul 20, 2026
Conversation
…ptied (vectorize-io#2507) The mental-model edit dialog sent `tags: tags.length > 0 ? tags : undefined`, so clearing the tags field made the key drop out of the PATCH body (JSON.stringify omits undefined). The dataplane treats an absent `tags` field as "unchanged" (`if tags is not None` in `update_mental_model`), so the previous tags survived and refreshes kept filtering by them — the only workaround was delete + recreate. Always send the `tags` array, including the empty array, so emptying the field sends `tags: []` and the backend clears them. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
3 tasks
nicoloboschi
approved these changes
Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2507. In the control-plane mental-model edit dialog, emptying the tags field and saving did not clear the tags — the old tags persisted, and refreshes kept filtering by them. The only workaround was to delete and recreate the mental model.
Root cause
UpdateMentalModelDialog.handleUpdatebuilt the PATCH payload as:When the field is emptied,
tagsis[], so this sendsundefined.JSON.stringifydropsundefinedkeys, so the PATCH body arrives at the dataplane with notagsfield. The dataplane update path treats an absent field as "leave unchanged" (if tags is not None:inupdate_mental_model), so the previously stored tags are kept. This matches the reported symptom exactly.Note the dataplane already clears correctly when it receives
tags: []; the bug was purely the client omitting the field.Fix
Send the
tagsarray unconditionally, including the empty array:Now emptying the field sends
tags: [], and the backend clears the tags.Why this approach
tagshere is always astring[](built viasplit/map/filter), never null/undefined — so the change affects only the empty case. Every non-empty case is byte-for-byte identical to before.mentalModel.tagsand re-seeded on open / model change, so saving without touching tags re-sends the existing tags, not an empty list.Scope
Limited to the flat
tagsfield, as reported. The same? … : undefinedpattern exists for the trigger fields in this form, so clearing those via the UI may have the same class of issue — deliberately left out of this fix and can be tracked separately.The create dialog keeps
tags.length > 0 ? tags : undefined, which is correct there: create has no prior state and the server coerces[]→Noneanyway.Tests
No test was added or updated:
UpdateMentalModelDialog, or theupdateMentalModelclient method, so there is nothing to update.environment: "node"and no DOM testing tooling (@testing-library, jsdom/happy-dom). There is no harness today that renders the dialog and asserts on the emptied-field →tags: []behavior, which is where the bug lives.If maintainers prefer, a lightweight client-level contract test (assert the PATCH body carries
tags: []) or a new component-test harness can be added as a follow-up.🤖 Generated with Claude Code