Repository navigation
feat(inner_api): add endpoint to invalidate plugin model providers cache - #39468
Merged
Merged
Conversation
Enterprise installs plugins into a workspace by talking to the plugin daemon directly, so Dify never learns that a tenant's cached model provider list is stale and serves it for the full 24h TTL. Expose the existing PluginService.invalidate_plugin_model_providers_cache over the inner API so enterprise can drop the cache for the tenants it just changed. Batching is left to the caller.
Contributor
Pyrefly Type Coverage
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #39468 +/- ##
==========================================
- Coverage 86.10% 85.93% -0.18%
==========================================
Files 5073 5031 -42
Lines 286857 281256 -5601
Branches 57225 55249 -1976
==========================================
- Hits 247006 241689 -5317
+ Misses 35115 34831 -284
Partials 4736 4736
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
GareArc
marked this pull request as ready for review
July 24, 2026 00:36
wylswz
approved these changes
Jul 27, 2026
GareArc
added a commit
that referenced
this pull request
Jul 27, 2026
…iders cache (#39468)" This reverts commit b6099d0. The endpoint existed so an external installer could drop a tenant's provider cache after installing plugins behind this service's back. Disabling the cache outright removes the need: there is nothing to invalidate, and the endpoint has no caller. PluginService.invalidate_plugin_model_providers_cache stays. It predates the endpoint and is still called from this service's own plugin lifecycle paths.
GareArc
added a commit
that referenced
this pull request
Jul 27, 2026
…iders cache (#39468)" This reverts commit b6099d0. The endpoint existed so an external installer could drop a tenant's provider cache after installing plugins behind this service's back. Disabling the cache outright removes the need: there is nothing to invalidate, and the endpoint has no caller. PluginService.invalidate_plugin_model_providers_cache stays. It predates the endpoint and is still called from this service's own plugin lifecycle paths.
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.
What
Adds
POST /inner/api/enterprise/workspace/plugin-model-providers/invalidate, which drops the cached model provider list for a batch of tenants.The handler delegates to the existing
PluginService.invalidate_plugin_model_providers_cache, so Dify keeps sole ownership of the cache key layout and the generation counter — no new invalidation logic is introduced.Why
Dify caches a tenant's model providers under
plugin_model_providers:tenant_id:<t>:generation:<n>for 24h, and only invalidates it from its own plugin lifecycle code and task-polling endpoints.Dify Enterprise installs plugins into a workspace by calling the plugin daemon directly, which bypasses those paths entirely. Dify never learns the cache is stale, so a plugin assigned from the enterprise admin console does not show up in the workspace's model provider list. If the tenant had no providers when the list was first cached, an empty list is served for the full TTL.
This endpoint gives enterprise a supported way to say "this tenant changed" without reaching into Dify's Redis keys.
Testing
Unit tests cover payload validation (including rejection of unknown fields), one invalidation per tenant in order, and the empty-list and missing-payload no-ops.