Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Sep 4, 2024
Merged

Conversation

jim60105
Copy link
Contributor

@jim60105 jim60105 commented Sep 3, 2024

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.)

#3981

TypeError: '<' not supported between instances of 'NoneType' and 'int'

Signed-off-by: 陳鈞 <[email protected]>
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🐞 bug Something isn't working labels Sep 3, 2024
@crazywoola
Copy link
Member

Thank you very much for your discovery. :)

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Sep 4, 2024
@crazywoola crazywoola merged commit 80d14c9 into langgenius:main Sep 4, 2024
6 checks passed
ZhouhaoJiang added a commit that referenced this pull request Sep 4, 2024
* refs/heads/main: (219 commits)
  Revert "fix: an issue of keyword search feature in application log list" (#7949)
  chore: #7943 i18n (#7948)
  fix(api): Code-Based Extension cause error on position map sorting (#7934)
  Chore/add roadmap (#7943)
  Chore/add default step 1x url (#7933)
  fix rerank model value is empty string (#7937)
  chore: #7603 i18n (#7931)
  Fix/segment create with api (#7928)
  improve the notion table extract (#7925)
  fix: frontend handle sometimes server not generate the wrong follow up data struct (#7916)
  feat: support auto generate i18n translate (#6964)
  chore: Update versions to 0.7.3 (#7895)
  chore(Dockerfile): Bump expat to 2.6.2-2 (#7904)
  fix: correct typo in the setting screen (#7897)
  feat: allow users to use the app icon as the answer icon (#7888)
  ignore linked images when image id is none (#7890)
  Add Russian language (#7860)
  fix: fixed typo on loading reranking_mode (#7887)
  Add perplexity search as a new tool (#7861)
  fix: glm models prices and max_tokens correction (#7882)
  ...

# Conflicts:
#	api/core/workflow/nodes/question_classifier/question_classifier_node.py
mehrajagdish pushed a commit to Sbazar-GmbH/dify that referenced this pull request Sep 6, 2024
cuiks pushed a commit to cuiks/dify that referenced this pull request Sep 26, 2024
idonotknow pushed a commit to AceDataCloud/Dify that referenced this pull request Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot load custom Moderation extension
2 participants