[PR #23182] fix: prevent client-side crashes from null/undefined plugin data in workflow (#23154) #30190

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

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

State: closed
Merged: Yes


Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #23154.

Summary

This PR completely resolves the client-side application crashes that occur when adding specific plugin tools to workflows. The issue was caused by calling .split() method on null or undefined values in plugin identifier processing and variable parsing logic.

Root Cause Analysis:

  • Primary crash point: SwitchPluginVersion component attempting uniqueIdentifier.split(':') on null values
  • Secondary crash points: Multiple useSingleRunFormParams hooks calling item.variable.slice(1, -1).split('.') on invalid data
  • Impact: Complete application white screen with "Application error: a client-side exception has occurred while loading..." message

Fix Strategy:

  • Defensive Programming: Added null/undefined checks before string operations
  • Graceful Degradation: Components return safely instead of crashing
  • Data Filtering: Invalid variable processing results are filtered out
  • React Hooks Compliance: All fixes follow React Hooks rules and patterns

Files Modified:

  • SwitchPluginVersion component: Added safe plugin identifier handling
  • 6 workflow node type hooks: Added defensive variable processing
    • tool/use-single-run-form-params.ts
    • agent/use-single-run-form-params.ts
    • http/use-single-run-form-params.ts
    • llm/use-single-run-form-params.ts
    • parameter-extractor/use-single-run-form-params.ts
    • question-classifier/use-single-run-form-params.ts

Testing:

  • Added comprehensive test suite with 11 test cases covering all crash scenarios
  • Tests verify both error prevention and functional correctness
  • All edge cases and boundary conditions are covered

Screenshots

N/A

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/23182 **State:** closed **Merged:** Yes --- > [!IMPORTANT] > > 1. Make sure you have read our [contribution guidelines](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) > 2. Ensure there is an associated issue and you have been assigned to it > 3. Use the correct syntax to link this PR: Fixes #23154. ## Summary This PR completely resolves the client-side application crashes that occur when adding specific plugin tools to workflows. The issue was caused by calling `.split()` method on `null` or `undefined` values in plugin identifier processing and variable parsing logic. **Root Cause Analysis:** - **Primary crash point**: `SwitchPluginVersion` component attempting `uniqueIdentifier.split(':')` on null values - **Secondary crash points**: Multiple `useSingleRunFormParams` hooks calling `item.variable.slice(1, -1).split('.')` on invalid data - **Impact**: Complete application white screen with "Application error: a client-side exception has occurred while loading..." message **Fix Strategy:** - **Defensive Programming**: Added null/undefined checks before string operations - **Graceful Degradation**: Components return safely instead of crashing - **Data Filtering**: Invalid variable processing results are filtered out - **React Hooks Compliance**: All fixes follow React Hooks rules and patterns **Files Modified:** - `SwitchPluginVersion` component: Added safe plugin identifier handling - 6 workflow node type hooks: Added defensive variable processing - `tool/use-single-run-form-params.ts` - `agent/use-single-run-form-params.ts` - `http/use-single-run-form-params.ts` - `llm/use-single-run-form-params.ts` - `parameter-extractor/use-single-run-form-params.ts` - `question-classifier/use-single-run-form-params.ts` **Testing:** - Added comprehensive test suite with 11 test cases covering all crash scenarios - Tests verify both error prevention and functional correctness - All edge cases and boundary conditions are covered ## Screenshots N/A ## 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:47:01 -05:00
yindo closed this issue 2026-02-21 20:47:01 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#30190