Skip to content

Conversation

@wylswz
Copy link

@wylswz wylswz commented Dec 8, 2025

Pull Request Checklist

An error occurred in dynamic-options API when trying to get dynamic parameters for search repository tool of github plugin. get_trigger_event_handler_safely seems not safely handling ValueError

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/dify_plugin/core/server/io_server.py", line 94, in _execute_request_in_thread
    self._execute_request(
  File "/usr/local/lib/python3.12/site-packages/dify_plugin/plugin.py", line 455, in _execute_request
    response = self.dispatch(session, data)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/dify_plugin/core/server/router.py", line 79, in dispatch
    return route.func(session, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/dify_plugin/core/server/router.py", line 72, in wrapper
    return f(session, data)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/dify_plugin/core/plugin_executor.py", line 607, in fetch_parameter_options
    action_instance: DynamicSelectProtocol | None = self._get_dynamic_parameter_action(session=session, data=data)
                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/dify_plugin/core/plugin_executor.py", line 453, in _get_dynamic_parameter_action
    trigger_event: Event | None = self.registration.try_get_trigger_event_handler(
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/dify_plugin/core/plugin_registration.py", line 520, in try_get_trigger_event_handler
    return self.trigger_factory.get_trigger_event_handler_safely(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/dify_plugin/core/trigger_factory.py", line 143, in get_trigger_event_handler_safely
    entry = self._get_entry(provider_name)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/dify_plugin/core/trigger_factory.py", line 181, in _get_entry
    raise ValueError(f"Trigger provider `{provider_name}` not found") from exc
ValueError: Trigger provider `github` not found
127.0.0.1 - - [2025-12-08 07:42:06] "POST /invoke?action=fetch_parameter_options HTTP/1.0" 200 410 0.001878
Unexpected error occurred when executing request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/dify_plugin/core/trigger_factory.py", line 179, in _get_entry
    return self._providers[provider_name]
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
KeyError: 'github'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/dify_plugin/core/server/io_server.py", line 94, in _execute_request_in_thread
    self._execute_request(
  File "/usr/local/lib/python3.12/site-packages/dify_plugin/plugin.py", line 455, in _execute_request
    response = self.dispatch(session, data)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/dify_plugin/core/server/router.py", line 79, in dispatch
    return route.func(session, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/dify_plugin/core/server/router.py", line 72, in wrapper
    return f(session, data)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/dify_plugin/core/plugin_executor.py", line 607, in fetch_parameter_options
    action_instance: DynamicSelectProtocol | None = self._get_dynamic_parameter_action(session=session, data=data)
                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/dify_plugin/core/plugin_executor.py", line 453, in _get_dynamic_parameter_action
    trigger_event: Event | None = self.registration.try_get_trigger_event_handler(
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/dify_plugin/core/plugin_registration.py", line 520, in try_get_trigger_event_handler
    return self.trigger_factory.get_trigger_event_handler_safely(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/dify_plugin/core/trigger_factory.py", line 143, in get_trigger_event_handler_safely
    entry = self._get_entry(provider_name)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/dify_plugin/core/trigger_factory.py", line 181, in _get_entry
    raise ValueError(f"Trigger provider `{provider_name}` not found") from exc
ValueError: Trigger provider `github` not found

Compatibility Check

  • I have checked whether this change affects the backward compatibility of the plugin declared in README.md
  • I have checked whether this change affects the forward compatibility of the plugin declared in README.md
  • If this change introduces a breaking change, I have discussed it with the project maintainer and specified the release version in the README.md
  • I have described the compatibility impact and the corresponding version number in the PR description
  • I have checked whether the plugin version is updated in the README.md

Available Checks

  • Code has passed local tests
  • Relevant documentation has been updated (if necessary)

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @wylswz, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug in the plugin's dynamic parameter retrieval mechanism. Previously, if a requested trigger provider was not registered, the system would encounter a ValueError and crash. The changes introduce a try-except block to gracefully handle such scenarios, ensuring that the get_trigger_event_handler_safely method returns None instead of raising an exception, thus improving the stability and resilience of the plugin's API interactions.

Highlights

  • Error Handling Improvement: Implemented robust error handling within the get_trigger_event_handler_safely method to prevent crashes when a trigger provider is not found.
  • Bug Fix: Resolved an issue where the dynamic-options API would fail to retrieve dynamic parameters, specifically for the 'github' plugin, due to an unhandled ValueError when the trigger provider was missing.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes a ValueError that occurs when trying to get a trigger event handler for a provider that doesn't exist. The fix correctly wraps the code in a try...except block to handle the error gracefully. I've added one suggestion to improve the code's readability and robustness by narrowing the scope of the try block.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@wylswz
Copy link
Author

wylswz commented Dec 8, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes a ValueError in get_trigger_event_handler_safely that occurred when a trigger provider was not found. The change correctly catches the exception and returns None, which is the expected behavior for a 'safe' method. The fix is correct and effectively resolves the bug. I have provided one suggestion to refactor the implementation to be more Pythonic by using the .get() dictionary method instead of a try-except block, which improves readability and conciseness.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant