[PR #23104] fix(web): make iteration panel respect MAX_PARALLEL_LIMIT environment variable (#23083) #30166

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

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

State: closed
Merged: Yes


Fixes: #23083

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 #<issue number>.

Summary

This PR fixes issue #23083 where the MAX_PARALLEL_LIMIT environment variable was not taking effect in the iteration panel. The iteration panel was using a hardcoded MAX_ITERATION_PARALLEL_NUM constant (always 10) instead of respecting the dynamic PARALLEL_LIMIT configuration derived from the environment variable.

Root Cause

  • The iteration panel imported and used MAX_ITERATION_PARALLEL_NUM = 10 (hardcoded)
  • The environment variable MAX_PARALLEL_LIMIT was correctly parsed into PARALLEL_LIMIT but not used by UI components
  • Missing error handling for invalid environment variable values (could result in NaN)

Changes Made

  1. Fixed UI Components: Updated iteration/panel.tsx to use PARALLEL_LIMIT instead of hardcoded MAX_ITERATION_PARALLEL_NUM
  2. Enhanced Error Handling: Improved environment variable parsing in constants.ts with proper validation for invalid/empty/negative values
  3. Comprehensive Testing: Added 11 test cases covering environment variable parsing, UI integration, edge cases, and backward compatibility

Additional Improvements

  • Error Boundary: Added !Number.isNaN(parsed) && parsed > 0 validation to prevent invalid configurations
  • Fallback Mechanism: Invalid values now properly fallback to default value (10)
  • Code Quality: Fixed all ESLint violations (41 issues resolved)
  • Backward Compatibility: Preserved MAX_ITERATION_PARALLEL_NUM constant for existing code

Test Results

Test Suites: 1 passed, 1 total
Tests: 11 passed, 11 total
ESLint: 0 errors, 0 warnings
Code Coverage: constants.ts 99.35%

Test Coverage Breakdown:

  • Environment variable parsing (6 tests): Valid values, invalid values, empty values, negative values, float numbers
  • UI component integration (2 tests): Environment configuration takes effect, UI consistency
  • Legacy compatibility (2 tests): Backward compatibility, old vs new constant behavior
  • Constants validation (1 test): Type checking and relationships

Validation

Before this fix:

  • Setting MAX_PARALLEL_LIMIT=20 → UI still shows max=10 (hardcoded)
  • Invalid values like MAX_PARALLEL_LIMIT=invalid → Could result in NaN

After this fix:

  • Setting MAX_PARALLEL_LIMIT=20 → UI correctly shows max=20
  • Invalid values properly fallback to default value 10
  • All edge cases handled gracefully

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/23104 **State:** closed **Merged:** Yes --- Fixes: #23083 > [!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 #<issue number>`. ## Summary This PR fixes issue #23083 where the `MAX_PARALLEL_LIMIT` environment variable was not taking effect in the iteration panel. The iteration panel was using a hardcoded `MAX_ITERATION_PARALLEL_NUM` constant (always 10) instead of respecting the dynamic `PARALLEL_LIMIT` configuration derived from the environment variable. ### Root Cause - The iteration panel imported and used `MAX_ITERATION_PARALLEL_NUM = 10` (hardcoded) - The environment variable `MAX_PARALLEL_LIMIT` was correctly parsed into `PARALLEL_LIMIT` but not used by UI components - Missing error handling for invalid environment variable values (could result in `NaN`) ### Changes Made 1. **Fixed UI Components**: Updated `iteration/panel.tsx` to use `PARALLEL_LIMIT` instead of hardcoded `MAX_ITERATION_PARALLEL_NUM` 2. **Enhanced Error Handling**: Improved environment variable parsing in `constants.ts` with proper validation for invalid/empty/negative values 3. **Comprehensive Testing**: Added 11 test cases covering environment variable parsing, UI integration, edge cases, and backward compatibility ### Additional Improvements - **Error Boundary**: Added `!Number.isNaN(parsed) && parsed > 0` validation to prevent invalid configurations - **Fallback Mechanism**: Invalid values now properly fallback to default value (10) - **Code Quality**: Fixed all ESLint violations (41 issues resolved) - **Backward Compatibility**: Preserved `MAX_ITERATION_PARALLEL_NUM` constant for existing code ### Test Results ✅ Test Suites: 1 passed, 1 total ✅ Tests: 11 passed, 11 total ✅ ESLint: 0 errors, 0 warnings ✅ Code Coverage: constants.ts 99.35% **Test Coverage Breakdown:** - Environment variable parsing (6 tests): Valid values, invalid values, empty values, negative values, float numbers - UI component integration (2 tests): Environment configuration takes effect, UI consistency - Legacy compatibility (2 tests): Backward compatibility, old vs new constant behavior - Constants validation (1 test): Type checking and relationships ### Validation Before this fix: - Setting `MAX_PARALLEL_LIMIT=20` → UI still shows max=10 (hardcoded) - Invalid values like `MAX_PARALLEL_LIMIT=invalid` → Could result in `NaN` After this fix: - Setting `MAX_PARALLEL_LIMIT=20` → UI correctly shows max=20 ✅ - Invalid values properly fallback to default value 10 ✅ - All edge cases handled gracefully ✅ ## 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:46:58 -05:00
yindo closed this issue 2026-02-21 20:46:58 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#30166