[PR #7934] fix(api): Code-Based Extension cause error on position map sorting #25875

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

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

State: closed
Merged: Yes


Fixes #3981 and should continue to track the remain issue at #6528.

Note: The Code-Based Extension still does not appear on the interface.

I am submitting this PR mainly to explain my findings in the error, in order to save time for the next developer fixing the Code-Based Extension.

Checklist:

Important

Please review the checklist below before submitting your pull request.

  • Please open an issue before creating a PR or link to an existing issue
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

Description

The issue is because there is None in the position_map.

This piece of code assigns None to position and stores it in position_map[extension_name] when not entering the if statement.
https://github.com/langgenius/dify/blob/main/api/core/extension/extensible.py#L60-L68

This implementation ensures that when no value is get from the position_map, it uses infinity as the default value.
But there's None inside the position_map.
Then it was taken out for comparison, and the error occurred.
https://github.com/langgenius/dify/blob/main/api/core/helper/position_helper.py#L120

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update, included: Dify Document
  • Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement
  • Dependency upgrade

Testing Instructions

This error occurs at startup and causes the program to exit immediately when you have Code-Based Extension in the external_data_tool folder.
After the correction, the error message disappeared and the api started normally.
(But the Code-Based Extension still doesn't show up at frontend.)

**Original Pull Request:** https://github.com/langgenius/dify/pull/7934 **State:** closed **Merged:** Yes --- Fixes #3981 and should continue to track the remain issue at #6528. **Note: The Code-Based Extension still does not appear on the interface.** I am submitting this PR mainly to explain my findings in the error, in order to save time for the next developer fixing the Code-Based Extension. # Checklist: > [!IMPORTANT] > Please review the checklist below before submitting your pull request. - [x] Please open an issue before creating a PR or link to an existing issue - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods # Description The issue is because there is None in the `position_map`. This piece of code assigns None to `position` and stores it in `position_map[extension_name]` when not entering the if statement. https://github.com/langgenius/dify/blob/main/api/core/extension/extensible.py#L60-L68 This implementation ensures that when no value is get from the `position_map`, it uses infinity as the default value. But there's None inside the `position_map`. Then it was taken out for comparison, and the error occurred. https://github.com/langgenius/dify/blob/main/api/core/helper/position_helper.py#L120 ## Type of Change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [ ] Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement - [ ] Dependency upgrade # Testing Instructions This error occurs at startup and causes the program to exit immediately when you have Code-Based Extension in the external_data_tool folder. After the correction, the error message disappeared and the api started normally. (But the Code-Based Extension still doesn't show up at frontend.)
yindo added the pull-request label 2026-02-21 20:28:28 -05:00
yindo closed this issue 2026-02-21 20:28:30 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#25875