Plugin fails validation in remote debug mode despite following official guide #92

Open
opened 2026-02-16 00:19:44 -05:00 by yindo · 3 comments
Owner

Originally created by @nktpv on GitHub (Apr 16, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.2.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Created plugin using the dify-plugin-sdk and followed official development guide.

Set .env for debug on my local machine:

INSTALL_METHOD=remote
REMOTE_INSTALL_HOST=localhost
REMOTE_INSTALL_PORT=5003
REMOTE_INSTALL_KEY=****-****-****-****-****

Launched plugin with:

python -m main

Plugin starts correctly without any errors.

Image

Go to Dify UI → Settings → Model supplier → API-KEY Tune.

But instead of confirming the correctly entered key, I have to wait and then I get a critical error.

Image

AND

Image

✔️ Expected Behavior

Plugin should pass validation and appear as a working debug plugin in the UI, assuming the correct API_KEY is provided and plugin is running as expected.

Actual Behavior

On the backend, an exception is raised in the plugin daemon, and the plugin crashes during credential validation. Here’s an excerpt from the logs showing the plugin exiting right after the credential validation attempt:

2025-04-16 21:29:32 api-1            | Traceback (most recent call last):
2025-04-16 21:29:32 api-1            |   File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request
2025-04-16 21:29:32 api-1            |     rv = self.dispatch_request()
2025-04-16 21:29:32 api-1            |          ^^^^^^^^^^^^^^^^^^^^^^^
2025-04-16 21:29:32 api-1            |   File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request
2025-04-16 21:29:32 api-1            |     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
2025-04-16 21:29:32 api-1            |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-04-16 21:29:32 api-1            |   File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 489, in wrapper
2025-04-16 21:29:32 api-1            |     resp = resource(*args, **kwargs)
2025-04-16 21:29:32 api-1            |            ^^^^^^^^^^^^^^^^^^^^^^^^^
2025-04-16 21:29:32 api-1            |   File "/app/api/.venv/lib/python3.12/site-packages/flask/views.py", line 110, in view
2025-04-16 21:29:32 api-1            |     return current_app.ensure_sync(self.dispatch_request)(**kwargs)  # type: ignore[no-any-return]
2025-04-16 21:29:32 api-1            |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-04-16 21:29:32 api-1            |   File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 604, in dispatch_request
2025-04-16 21:29:32 api-1            |     resp = meth(*args, **kwargs)
2025-04-16 21:29:32 api-1            |            ^^^^^^^^^^^^^^^^^^^^^
2025-04-16 21:29:32 api-1            |   File "/app/api/controllers/console/wraps.py", line 198, in decorated
2025-04-16 21:29:32 api-1            |     return view(*args, **kwargs)
2025-04-16 21:29:32 api-1            |            ^^^^^^^^^^^^^^^^^^^^^
2025-04-16 21:29:32 api-1            |   File "/app/api/libs/login.py", line 94, in decorated_view
2025-04-16 21:29:32 api-1            |     return current_app.ensure_sync(func)(*args, **kwargs)
2025-04-16 21:29:32 api-1            |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-04-16 21:29:32 api-1            |   File "/app/api/controllers/console/wraps.py", line 30, in decorated
2025-04-16 21:29:32 api-1            |     return view(*args, **kwargs)
2025-04-16 21:29:32 api-1            |            ^^^^^^^^^^^^^^^^^^^^^
2025-04-16 21:29:32 api-1            |   File "/app/api/controllers/console/workspace/model_providers.py", line 102, in post
2025-04-16 21:29:32 api-1            |     model_provider_service.save_provider_credentials(
2025-04-16 21:29:32 api-1            |   File "/app/api/services/model_provider_service.py", line 145, in save_provider_credentials
2025-04-16 21:29:32 api-1            |     provider_configuration.add_or_update_custom_credentials(credentials)
2025-04-16 21:29:32 api-1            |   File "/app/api/core/entities/provider_configuration.py", line 257, in add_or_update_custom_credentials
2025-04-16 21:29:32 api-1            |     provider_record, credentials = self.custom_credentials_validate(credentials)
2025-04-16 21:29:32 api-1            |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-04-16 21:29:32 api-1            |   File "/app/api/core/entities/provider_configuration.py", line 240, in custom_credentials_validate
2025-04-16 21:29:32 api-1            |     credentials = model_provider_factory.provider_credentials_validate(
2025-04-16 21:29:32 api-1            |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-04-16 21:29:32 api-1            |   File "/app/api/core/model_runtime/model_providers/model_provider_factory.py", line 156, in provider_credentials_validate
2025-04-16 21:29:32 api-1            |     self.plugin_model_manager.validate_provider_credentials(
2025-04-16 21:29:32 api-1            |   File "/app/api/core/plugin/manager/model.py", line 97, in validate_provider_credentials
2025-04-16 21:29:32 api-1            |     for resp in response:
2025-04-16 21:29:32 api-1            |                 ^^^^^^^^
2025-04-16 21:29:32 api-1            |   File "/app/api/core/plugin/manager/base.py", line 189, in _request_with_plugin_daemon_response_stream
2025-04-16 21:29:32 api-1            |     self._handle_plugin_daemon_error(error.error_type, error.message)
2025-04-16 21:29:32 api-1            |   File "/app/api/core/plugin/manager/base.py", line 221, in _handle_plugin_daemon_error
2025-04-16 21:29:32 api-1            |     raise PluginInvokeError(description=message)
2025-04-16 21:29:32 api-1            | core.plugin.manager.exc.PluginInvokeError: PluginInvokeError: {"args":{},"error_type":"ConnectionClosedError","message":"Connection closed unexpectedly"}

In addition, the logs indicate that some sql query did not find any records in the plugin_deamon module:

2025-04-16 21:29:32 plugin_daemon-1  | 
2025-04-16 21:29:32 plugin_daemon-1  | 2025/04/16 18:29:32 /app/internal/db/executor.go:259 record not found
2025-04-16 21:29:32 plugin_daemon-1  | [1.782ms] [rows:0] SELECT * FROM "plugin_installations" WHERE plugin_id = '555d3b17-38a6-43d1-89c1-315b6bb0ef32/yandexgpt' AND tenant_id = '555d3b17-38a6-43d1-89c1-315b6bb0ef32' ORDER BY "plugin_installations"."id" LIMIT 1
2025-04-16 21:29:32 plugin_daemon-1  | 
2025-04-16 21:29:32 plugin_daemon-1  | 2025/04/16 18:29:32 /app/internal/db/executor.go:259 record not found
2025-04-16 21:29:32 plugin_daemon-1  | [0.850ms] [rows:0] SELECT * FROM "plugins" WHERE plugin_unique_identifier = '555d3b17-38a6-43d1-89c1-315b6bb0ef32/yandexgpt:0.0.1@b7321013540184cce255870deab8870d7e51feb04ab17508d072135dfa8dbfbf' AND plugin_id = '555d3b17-38a6-43d1-89c1-315b6bb0ef32/yandexgpt' AND install_type = 'remote' ORDER BY "plugins"."id" LIMIT 1 FOR UPDATE

However, when running the same queries manually on the same database, they return rows, not 0 rows as reflected in the logs. This could indicate a problem with transactions, isolation, or the plugin's environment at startup. It is suspected that the plugin is running in a different context or container where the database is not synchronized or not properly accessible.

The message is also observed:
runtime_lifetime.go:42: [ERROR]add plugin to cluster failed: plugin has been registered.
which may indicate problems with reinitialization or registration of an existing plugin.

All this leads to plugin crash with ConnectionClosedError and impossibility to complete provider configuration.

Originally created by @nktpv on GitHub (Apr 16, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.2.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Created plugin using the `dify-plugin-sdk` and followed official development [guide](https://docs.dify.ai/plugins/quick-start/develop-plugins/model-plugin). Set `.env` for debug on my local machine: ```bash INSTALL_METHOD=remote REMOTE_INSTALL_HOST=localhost REMOTE_INSTALL_PORT=5003 REMOTE_INSTALL_KEY=****-****-****-****-**** ``` Launched plugin with: ```bash python -m main ``` Plugin starts correctly without any errors. ![Image](https://github.com/user-attachments/assets/70f465fa-9ae6-40c6-9a0e-c289154d37b5) Go to Dify UI → Settings → Model supplier → API-KEY Tune. But instead of confirming the correctly entered key, I have to wait and then I get a critical error. ![Image](https://github.com/user-attachments/assets/4fd28621-967a-47df-859e-3ceeeb7411aa) AND ![Image](https://github.com/user-attachments/assets/d7d5c40f-a2f5-4a39-bbab-2aafe21decf8) ### ✔️ Expected Behavior Plugin should pass validation and appear as a working debug plugin in the UI, assuming the correct `API_KEY` is provided and plugin is running as expected. ### ❌ Actual Behavior On the backend, an exception is raised in the plugin daemon, and the plugin crashes during credential validation. Here’s an excerpt from the logs showing the plugin exiting right after the credential validation attempt: ``` 2025-04-16 21:29:32 api-1 | Traceback (most recent call last): 2025-04-16 21:29:32 api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request 2025-04-16 21:29:32 api-1 | rv = self.dispatch_request() 2025-04-16 21:29:32 api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ 2025-04-16 21:29:32 api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request 2025-04-16 21:29:32 api-1 | return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] 2025-04-16 21:29:32 api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-04-16 21:29:32 api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 489, in wrapper 2025-04-16 21:29:32 api-1 | resp = resource(*args, **kwargs) 2025-04-16 21:29:32 api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-04-16 21:29:32 api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/views.py", line 110, in view 2025-04-16 21:29:32 api-1 | return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return] 2025-04-16 21:29:32 api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-04-16 21:29:32 api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 604, in dispatch_request 2025-04-16 21:29:32 api-1 | resp = meth(*args, **kwargs) 2025-04-16 21:29:32 api-1 | ^^^^^^^^^^^^^^^^^^^^^ 2025-04-16 21:29:32 api-1 | File "/app/api/controllers/console/wraps.py", line 198, in decorated 2025-04-16 21:29:32 api-1 | return view(*args, **kwargs) 2025-04-16 21:29:32 api-1 | ^^^^^^^^^^^^^^^^^^^^^ 2025-04-16 21:29:32 api-1 | File "/app/api/libs/login.py", line 94, in decorated_view 2025-04-16 21:29:32 api-1 | return current_app.ensure_sync(func)(*args, **kwargs) 2025-04-16 21:29:32 api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-04-16 21:29:32 api-1 | File "/app/api/controllers/console/wraps.py", line 30, in decorated 2025-04-16 21:29:32 api-1 | return view(*args, **kwargs) 2025-04-16 21:29:32 api-1 | ^^^^^^^^^^^^^^^^^^^^^ 2025-04-16 21:29:32 api-1 | File "/app/api/controllers/console/workspace/model_providers.py", line 102, in post 2025-04-16 21:29:32 api-1 | model_provider_service.save_provider_credentials( 2025-04-16 21:29:32 api-1 | File "/app/api/services/model_provider_service.py", line 145, in save_provider_credentials 2025-04-16 21:29:32 api-1 | provider_configuration.add_or_update_custom_credentials(credentials) 2025-04-16 21:29:32 api-1 | File "/app/api/core/entities/provider_configuration.py", line 257, in add_or_update_custom_credentials 2025-04-16 21:29:32 api-1 | provider_record, credentials = self.custom_credentials_validate(credentials) 2025-04-16 21:29:32 api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-04-16 21:29:32 api-1 | File "/app/api/core/entities/provider_configuration.py", line 240, in custom_credentials_validate 2025-04-16 21:29:32 api-1 | credentials = model_provider_factory.provider_credentials_validate( 2025-04-16 21:29:32 api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-04-16 21:29:32 api-1 | File "/app/api/core/model_runtime/model_providers/model_provider_factory.py", line 156, in provider_credentials_validate 2025-04-16 21:29:32 api-1 | self.plugin_model_manager.validate_provider_credentials( 2025-04-16 21:29:32 api-1 | File "/app/api/core/plugin/manager/model.py", line 97, in validate_provider_credentials 2025-04-16 21:29:32 api-1 | for resp in response: 2025-04-16 21:29:32 api-1 | ^^^^^^^^ 2025-04-16 21:29:32 api-1 | File "/app/api/core/plugin/manager/base.py", line 189, in _request_with_plugin_daemon_response_stream 2025-04-16 21:29:32 api-1 | self._handle_plugin_daemon_error(error.error_type, error.message) 2025-04-16 21:29:32 api-1 | File "/app/api/core/plugin/manager/base.py", line 221, in _handle_plugin_daemon_error 2025-04-16 21:29:32 api-1 | raise PluginInvokeError(description=message) 2025-04-16 21:29:32 api-1 | core.plugin.manager.exc.PluginInvokeError: PluginInvokeError: {"args":{},"error_type":"ConnectionClosedError","message":"Connection closed unexpectedly"} ``` In addition, the logs indicate that some sql query did not find any records in the `plugin_deamon` module: ``` 2025-04-16 21:29:32 plugin_daemon-1 | 2025-04-16 21:29:32 plugin_daemon-1 | 2025/04/16 18:29:32 /app/internal/db/executor.go:259 record not found 2025-04-16 21:29:32 plugin_daemon-1 | [1.782ms] [rows:0] SELECT * FROM "plugin_installations" WHERE plugin_id = '555d3b17-38a6-43d1-89c1-315b6bb0ef32/yandexgpt' AND tenant_id = '555d3b17-38a6-43d1-89c1-315b6bb0ef32' ORDER BY "plugin_installations"."id" LIMIT 1 2025-04-16 21:29:32 plugin_daemon-1 | 2025-04-16 21:29:32 plugin_daemon-1 | 2025/04/16 18:29:32 /app/internal/db/executor.go:259 record not found 2025-04-16 21:29:32 plugin_daemon-1 | [0.850ms] [rows:0] SELECT * FROM "plugins" WHERE plugin_unique_identifier = '555d3b17-38a6-43d1-89c1-315b6bb0ef32/yandexgpt:0.0.1@b7321013540184cce255870deab8870d7e51feb04ab17508d072135dfa8dbfbf' AND plugin_id = '555d3b17-38a6-43d1-89c1-315b6bb0ef32/yandexgpt' AND install_type = 'remote' ORDER BY "plugins"."id" LIMIT 1 FOR UPDATE ``` However, when running the same queries manually on the same database, they return rows, not 0 rows as reflected in the logs. This could indicate a problem with transactions, isolation, or the plugin's environment at startup. It is suspected that the plugin is running in a different context or container where the database is not synchronized or not properly accessible. The message is also observed: `runtime_lifetime.go:42: [ERROR]add plugin to cluster failed: plugin has been registered`. which may indicate problems with reinitialization or registration of an existing plugin. All this leads to plugin crash with `ConnectionClosedError` and impossibility to complete provider configuration.
Author
Owner

@dosubot[bot] commented on GitHub (Apr 16, 2025):

I found two similar discussions that might be relevant to your issue:

  1. Can't configure the OpenAI plugin: This discussion is open and involves issues with configuring plugins, which might provide insights into your validation problem [1].

  2. After deploying v1.0-beta via Docker, plugins cannot be installed: This discussion is also open and deals with plugin installation issues, which could be related to your situation [2].

Regarding your issue, the ConnectionClosedError during credential validation suggests a problem with the connection between your plugin and the server. This error can occur if the connection is unexpectedly terminated, possibly due to network issues or server-side problems [3]. Additionally, the "record not found" error in the plugin_daemon module could be due to discrepancies in database transactions or isolation levels, where the plugin might be running in a different context or container, causing synchronization issues [4][5].

To address these issues, consider the following steps:

  • Check Network and Server Configuration: Ensure that your network settings and server configurations are correct, especially regarding the remote debug setup. Verify that the server is accessible and that there are no firewall or network restrictions causing the connection to close unexpectedly.

  • Database Synchronization: Investigate the database transaction settings and isolation levels. Ensure that the plugin and the database are correctly synchronized and accessible from the same context or container. This might involve checking the Docker setup and ensuring that all services are correctly linked and configured.

  • Plugin Registration: The error message "add plugin to cluster failed: plugin has been registered" indicates potential issues with reinitialization or registration of existing plugins. Ensure that the plugin registration process is correctly handled and that there are no conflicts with existing plugins [4].

These steps should help you diagnose and resolve the issues you're facing with plugin validation and registration.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Apr 16, 2025): <!-- Answer --> I found two similar discussions that might be relevant to your issue: 1. **[Can't configure the OpenAI plugin](https://github.com/langgenius/dify/discussions/18034)**: This discussion is open and involves issues with configuring plugins, which might provide insights into your validation problem <sup>[[1]](https://github.com/langgenius/dify/discussions/18034)</sup>. 2. **[After deploying v1.0-beta via Docker, plugins cannot be installed](https://github.com/langgenius/dify/discussions/12825)**: This discussion is also open and deals with plugin installation issues, which could be related to your situation <sup>[[2]](https://github.com/langgenius/dify/discussions/12825)</sup>. Regarding your issue, the `ConnectionClosedError` during credential validation suggests a problem with the connection between your plugin and the server. This error can occur if the connection is unexpectedly terminated, possibly due to network issues or server-side problems <sup>[[3]](https://github.com/langgenius/dify/blob/main/api/core/plugin/manager/base.py)</sup>. Additionally, the "record not found" error in the `plugin_daemon` module could be due to discrepancies in database transactions or isolation levels, where the plugin might be running in a different context or container, causing synchronization issues <sup>[[4]](https://github.com/langgenius/dify/issues/16830)</sup><sup>[[5]](https://github.com/langgenius/dify/issues/16925)</sup>. To address these issues, consider the following steps: - **Check Network and Server Configuration**: Ensure that your network settings and server configurations are correct, especially regarding the remote debug setup. Verify that the server is accessible and that there are no firewall or network restrictions causing the connection to close unexpectedly. - **Database Synchronization**: Investigate the database transaction settings and isolation levels. Ensure that the plugin and the database are correctly synchronized and accessible from the same context or container. This might involve checking the Docker setup and ensuring that all services are correctly linked and configured. - **Plugin Registration**: The error message "add plugin to cluster failed: plugin has been registered" indicates potential issues with reinitialization or registration of existing plugins. Ensure that the plugin registration process is correctly handled and that there are no conflicts with existing plugins <sup>[[4]](https://github.com/langgenius/dify/issues/16830)</sup>. These steps should help you diagnose and resolve the issues you're facing with plugin validation and registration. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/aeccd90b-8232-4d96-afb0-7e0b3afaaeaf?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/aeccd90b-8232-4d96-afb0-7e0b3afaaeaf?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/aeccd90b-8232-4d96-afb0-7e0b3afaaeaf?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/aeccd90b-8232-4d96-afb0-7e0b3afaaeaf?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/aeccd90b-8232-4d96-afb0-7e0b3afaaeaf?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/aeccd90b-8232-4d96-afb0-7e0b3afaaeaf?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/aeccd90b-8232-4d96-afb0-7e0b3afaaeaf?feedback_type=other)</sup>
Author
Owner

@filwu8 commented on GitHub (Apr 21, 2025):

我一直在日志中看到如下错误。
plugin_daemon-1 | 2025/04/21 06:13:08 /app/internal/db/executor.go:259 record not found

@filwu8 commented on GitHub (Apr 21, 2025): 我一直在日志中看到如下错误。 plugin_daemon-1 | 2025/04/21 06:13:08 /app/internal/db/executor.go:259 record not found
Author
Owner

@qq281541534 commented on GitHub (Apr 21, 2025):

我一直在日志中看到如下错误。 plugin_daemon-1 | 2025/04/21 06:13:08 /app/internal/db/executor.go:259 record not found

同样的问题

@qq281541534 commented on GitHub (Apr 21, 2025): > 我一直在日志中看到如下错误。 plugin_daemon-1 | 2025/04/21 06:13:08 /app/internal/db/executor.go:259 record not found 同样的问题
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-plugin-daemon#92