dify icon indicating copy to clipboard operation
dify copied to clipboard

IP policy saves wait for a list refresh after the server confirms success

Open lyzno1 opened this issue 2 weeks ago • 2 comments

Environment

Dify Cloud IP Policies settings. Follow-up to #46779, based on main at 64b3b93ed69.

Steps to reproduce

  1. Open Settings → IP Policies in a workspace with no policies and permission to manage them.
  2. Open Create an IP policy, enter a name and a valid CIDR, and submit it.
  3. Let the create request return the saved policy, then stall or fail the list refresh.

Actual behavior

The editor keeps showing a pending submission while the list refresh runs. If that refresh fails after the create request succeeded, the editor can close onto a list loading error with no visible policy or Add button.

Expected behavior

After the server confirms the save, show the policy from the response and close the editor without waiting for a second request. On first creation, move keyboard focus to Add once it is available. A refresh failure should leave the last confirmed list usable.

lyzno1 avatar Nov 20 '26 02:11 lyzno1

The wait extends beyond the policy-list refresh: both create and update return the shared invalidation promise from onSettled, which includes the group list, group details, and app bindings. That puts those refreshes on the mutation’s completion path. [1] [2]

There are two separate pieces to decouple:

  • Commit the returned group to the list cache before closing, and run reconciliation without returning its promise from the mutation callback. The current create handler only records the session, then waits for mutation success and the rendered cache snapshot before closing. [3] [4]
  • Preserve the management controls when cached data exists. Add currently requires !isError, even though the table can still render cached groups after a refresh failure. Initial-load failure and background-refresh failure need different handling. [5] [6]

A useful regression case is a successful save with reconciliation held unresolved, asserting that the returned policy is visible, the editor closes, and first-create focus reaches Add before releasing the refresh.

To reply, just mention @dosu.


Docs are dead. Just use Dosu.

Leave Feedback Ask Dosu about dify

dosubot[bot] avatar Nov 20 '26 02:11 dosubot[bot]

The submit handler is currently awaiting the list revalidation query instead of resolving on the POST response alone. When the subsequent list fetch fails or hangs, the whole view cascades into an error boundary because the cache wasn't populated from the creation payload.

Decoupling the modal lifecycle and populating the cache directly from the POST response fixes both the hang and the error screen:

Patch Preview (First 3 lines of verified fix):

const handleSubmit = async (formData: IPPolicyFormData) => {
  setIsSubmitting(true);
  try {
# ... [TRUNCATED — Full production patch & verification steps locked below]

grinem avatar Nov 20 '26 02:11 grinem