Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: remove unnecessary credentials of custom tool (#2621)

Yeuoly57ffecd0e5d2
diff --git a/web/app/components/tools/edit-custom-collection-modal/index.tsx b/web/app/components/tools/edit-custom-collection-modal/index.tsx
index 22416808b46..45e0a014ce0 100644
--- a/web/app/components/tools/edit-custom-collection-modal/index.tsx
+++ b/web/app/components/tools/edit-custom-collection-modal/index.tsx
@@ -118,6 +118,13 @@ const EditCustomCollectionModal: FC<Props> = ({
const handleSave = () => {
const postData = clone(customCollection)
delete postData.tools
+
+ if (postData.credentials.auth_type === AuthType.none) {
+ delete postData.credentials.api_key_header
+ delete postData.credentials.api_key_header_prefix
+ delete postData.credentials.api_key_value
+ }
+
if (isAdd) {
onAdd?.(postData)
return
diff --git a/web/app/components/tools/edit-custom-collection-modal/test-api.tsx b/web/app/components/tools/edit-custom-collection-modal/test-api.tsx
index b1a494317e7..2f79044da00 100644
--- a/web/app/components/tools/edit-custom-collection-modal/test-api.tsx
+++ b/web/app/components/tools/edit-custom-collection-modal/test-api.tsx
@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next'
import { useContext } from 'use-context-selector'
import { Settings01 } from '../../base/icons/src/vender/line/general'
import ConfigCredentials from './config-credentials'
-import type { Credential, CustomCollectionBackend, CustomParamSchema } from '@/app/components/tools/types'
+import { AuthType, type Credential, type CustomCollectionBackend, type CustomParamSchema } from '@/app/components/tools/types'
import Button from '@/app/components/base/button'
import Drawer from '@/app/components/base/drawer-plus'
import I18n from '@/context/i18n'
@@ -34,6 +34,13 @@ const TestApi: FC<Props> = ({
const { operation_id: toolName, parameters } = tool
const [parametersValue, setParametersValue] = useState<Record<string, string>>({})
const handleTest = async () => {
+ // clone test schema
+ const credentials = JSON.parse(JSON.stringify(tempCredential)) as Credential
+ if (credentials.auth_type === AuthType.none) {
+ delete credentials.api_key_header_prefix
+ delete credentials.api_key_header
+ delete credentials.api_key_value
+ }
const data = {
tool_name: toolName,
credentials: tempCredential,