Skip to content

fix(ui): seed RTK Query cache after create/update mutations#6217

Draft
jgaul3 wants to merge 2 commits into
flipt-io:v2from
jgaul3:jg/use-response-revision
Draft

fix(ui): seed RTK Query cache after create/update mutations#6217
jgaul3 wants to merge 2 commits into
flipt-io:v2from
jgaul3:jg/use-response-revision

Conversation

@jgaul3

@jgaul3 jgaul3 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Description

When I use flipt, I find I have to refresh a time or two after making changes for those changes to be reflected in the UI. I'm quite certain this is a read-after-write bug arising from using invalidatesTags rather than updating those tags. This PR updates them to generally use onQueryStarted instead.

This applies to creating, updating, and deleting flags and segments, as well as creating branches.

I tested things out locally but since it's partially a network thing that's mostly to confirm that basic processes still work.

Signed-off-by: Jon Gaul <jgaul3@gmail.com>
@jgaul3
jgaul3 requested a review from a team as a code owner July 16, 2026 04:59
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 16, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: request changes

The onQueryStarted cache-seeding correctly fixes read-after-write for creates and updates, but the delete mutations for flags and segments drop detail-cache invalidation entirely. After deletion, navigating back to the deleted item can serve stale cached data instead of a 404. Add back invalidation for the specific detail tags in deleteFlag and deleteSegment.

ui/src/app/flags/flagsApi.ts

  • major (L185): After deleteFlag succeeds, the getFlag cache entry for the deleted flag is never invalidated. If a user navigates back to the flag (browser back, direct URL, or recreated flag with the same key), RTK Query serves the old cached data instead of refetching. Keep invalidatesTags for the specific flag detail tag, or dispatch flagsApi.util.invalidateTags([{ type: 'Flag', id: environmentKey + '/' + namespaceKey + '/' + flagKey }]), alongside the onQueryStarted list update.

ui/src/app/segments/segmentsApi.ts

  • major (L176): deleteSegment has the same regression: the getSegment cache for the deleted segment is not cleared, so stale data can persist after deletion. Keep invalidatesTags for the specific segment detail tag, or dispatch segmentsApi.util.invalidateTags([{ type: 'Segment', id: environmentKey + '/' + namespaceKey + '/' + segmentKey }]), alongside the onQueryStarted list update.

🤖 Automated review by the Flipt PR review agent.

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.27%. Comparing base (22b8203) to head (babf277).

Additional details and impacted files
@@           Coverage Diff           @@
##               v2    #6217   +/-   ##
=======================================
  Coverage   62.27%   62.27%           
=======================================
  Files         145      145           
  Lines       14815    14815           
=======================================
  Hits         9226     9226           
  Misses       4829     4829           
  Partials      760      760           
Flag Coverage Δ
integrationtests 33.50% <ø> (ø)
unittests 53.85% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@erka

erka commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

@jgaul3 What does your deployment look like? I think the UI is hitting different Flipt instances while you're making changes.

@jgaul3

jgaul3 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@erka Apologies for the delay, let me check whether we've got some kind of cluster thing going on and get back to you 👍

@jgaul3
jgaul3 marked this pull request as draft July 21, 2026 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants