mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-20 19:59:11 +08:00
fix: wrap marketplace apis with try catch
This commit is contained in:
parent
7a2b2a04c9
commit
38cae29757
@ -24,6 +24,6 @@ def batch_fetch_plugin_manifests(plugin_ids: list[str]) -> Sequence[MarketplaceP
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
url = str(URL(str(dify_config.MARKETPLACE_API_URL)) / "api/v1/plugins/batch")
|
url = str(URL(str(dify_config.MARKETPLACE_API_URL)) / "api/v1/plugins/batch")
|
||||||
response = requests.get(url, json={"plugin_ids": plugin_ids})
|
response = requests.post(url, json={"plugin_ids": plugin_ids})
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
return [MarketplacePluginDeclaration(**plugin) for plugin in response.json()["plugins"]]
|
return [MarketplacePluginDeclaration(**plugin) for plugin in response.json()["plugins"]]
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import logging
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
from mimetypes import guess_type
|
from mimetypes import guess_type
|
||||||
|
|
||||||
@ -11,6 +12,8 @@ from core.plugin.manager.asset import PluginAssetManager
|
|||||||
from core.plugin.manager.debugging import PluginDebuggingManager
|
from core.plugin.manager.debugging import PluginDebuggingManager
|
||||||
from core.plugin.manager.plugin import PluginInstallationManager
|
from core.plugin.manager.plugin import PluginInstallationManager
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class PluginService:
|
class PluginService:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -29,7 +32,14 @@ class PluginService:
|
|||||||
manager = PluginInstallationManager()
|
manager = PluginInstallationManager()
|
||||||
plugins = manager.list_plugins(tenant_id)
|
plugins = manager.list_plugins(tenant_id)
|
||||||
plugin_ids = [plugin.plugin_id for plugin in plugins if plugin.source == PluginInstallationSource.Marketplace]
|
plugin_ids = [plugin.plugin_id for plugin in plugins if plugin.source == PluginInstallationSource.Marketplace]
|
||||||
manifests = {manifest.plugin_id: manifest for manifest in marketplace.batch_fetch_plugin_manifests(plugin_ids)}
|
try:
|
||||||
|
manifests = {
|
||||||
|
manifest.plugin_id: manifest for manifest in marketplace.batch_fetch_plugin_manifests(plugin_ids)
|
||||||
|
}
|
||||||
|
except Exception as e:
|
||||||
|
manifests = {}
|
||||||
|
logger.exception(f"failed to fetch plugin manifests: {e}")
|
||||||
|
|
||||||
for plugin in plugins:
|
for plugin in plugins:
|
||||||
if plugin.source == PluginInstallationSource.Marketplace:
|
if plugin.source == PluginInstallationSource.Marketplace:
|
||||||
if plugin.plugin_id in manifests:
|
if plugin.plugin_id in manifests:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user