fix(web): skip auth validation for local file datasource (#39856)

This commit is contained in:
非法操作 2026-07-31 17:55:48 +08:00 committed by GitHub
parent 37bf80dcf6
commit b4d93b02fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 4 deletions

View File

@ -69,19 +69,29 @@ describe('getDataSourceCheckParams', () => {
])
})
it('should mark an unauthorized datasource as not authed', () => {
it('should not require authorization for a local file datasource', () => {
const result = getDataSourceCheckParams(
createDataSourceData(),
[createDataSourceCollection()],
'en_US',
)
expect(result.notAuthed).toBe(false)
})
it('should mark an unauthorized online datasource as not authed', () => {
const result = getDataSourceCheckParams(
createDataSourceData({ provider_type: 'online_document' }),
[createDataSourceCollection()],
'en_US',
)
expect(result.notAuthed).toBe(true)
})
it('should mark as authed when is_authorized is true', () => {
const result = getDataSourceCheckParams(
createDataSourceData(),
createDataSourceData({ provider_type: 'online_document' }),
[createDataSourceCollection({ is_authorized: true })],
'en_US',
)

View File

@ -1,13 +1,14 @@
import type { DataSourceNodeType } from '../nodes/data-source/types'
import type { InputVar, ToolWithProvider } from '../types'
import { toolParametersToFormSchemas } from '@/app/components/tools/utils/to-form-schema'
import { DataSourceClassification } from '../nodes/data-source/types'
export const getDataSourceCheckParams = (
toolData: DataSourceNodeType,
dataSourceList: ToolWithProvider[],
language: string,
) => {
const { plugin_id, datasource_name } = toolData
const { plugin_id, provider_type, datasource_name } = toolData
const currentDataSource = dataSourceList.find((item) => item.plugin_id === plugin_id)
const currentDataSourceItem = currentDataSource?.tools.find(
(tool) => tool.name === datasource_name,
@ -30,7 +31,10 @@ export const getDataSourceCheckParams = (
})
return formInputs
})(),
notAuthed: !!currentDataSource?.allow_delete && !currentDataSource?.is_authorized,
notAuthed:
provider_type !== DataSourceClassification.localFile &&
!!currentDataSource?.allow_delete &&
!currentDataSource?.is_authorized,
language,
}
}