[PR #28243] fix: add app_id to Redis cache keys for trigger nodes to ensure uniqueness #31988

Closed
opened 2026-02-21 20:50:32 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/28243

State: closed
Merged: Yes


Fixes #28440

Summary

This PR fixes a Redis cache key uniqueness issue in trigger node services. The previous implementation used only node_id as the cache key, which could cause conflicts when different applications have nodes with the same node_id.

Problem

When multiple apps have trigger nodes with the same node_id, they would share the same Redis cache entry, leading to incorrect cached data being retrieved.

Before:

Cache key format: {CACHE_KEY}:{node_id}

After:

Cache key format: {CACHE_KEY}:{app_id}:{node_id}

Changes

  • api/services/trigger/trigger_service.py: Updated all Redis operations (GET/SET/DELETE) for plugin trigger node cache to include app_id
  • api/services/trigger/webhook_service.py: Applied the same fix for webhook trigger node cache

Impact

  • Ensures cache isolation between different applications
  • Prevents data corruption caused by cache key collisions
  • Maintains backward compatibility for the lock key pattern

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/28243 **State:** closed **Merged:** Yes --- Fixes #28440 ## Summary This PR fixes a Redis cache key uniqueness issue in trigger node services. The previous implementation used only `node_id` as the cache key, which could cause conflicts when different applications have nodes with the same `node_id`. ### Problem When multiple apps have trigger nodes with the same `node_id`, they would share the same Redis cache entry, leading to incorrect cached data being retrieved. **Before:** ``` Cache key format: {CACHE_KEY}:{node_id} ``` **After:** ``` Cache key format: {CACHE_KEY}:{app_id}:{node_id} ``` ### Changes - **api/services/trigger/trigger_service.py**: Updated all Redis operations (GET/SET/DELETE) for plugin trigger node cache to include `app_id` - **api/services/trigger/webhook_service.py**: Applied the same fix for webhook trigger node cache ### Impact - Ensures cache isolation between different applications - Prevents data corruption caused by cache key collisions - Maintains backward compatibility for the lock key pattern ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:50:32 -05:00
yindo closed this issue 2026-02-21 20:50:32 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#31988