mirror of
https://github.com/langgenius/dify.git
synced 2026-09-05 08:48:10 +08:00
fix(web): guard LLM node model_selector against persisted null (#41707)
This commit is contained in:
parent
b015aa416f
commit
8f7cca3ae2
@ -1,4 +1,8 @@
|
||||
import type { EnvironmentVariable, ModelConfig } from '@/app/components/workflow/types'
|
||||
import type {
|
||||
EnvironmentVariable,
|
||||
ModelConfig,
|
||||
ValueSelector,
|
||||
} from '@/app/components/workflow/types'
|
||||
import { AppModeEnum } from '@/types/app'
|
||||
import {
|
||||
getLLMEnvironmentModel,
|
||||
@ -160,5 +164,14 @@ describe('llm utils', () => {
|
||||
expect(isEnvironmentModelSource(selector)).toBe(false)
|
||||
expect(resolveLLMNodeModel(model, selector, environmentVariables)).toBe(model)
|
||||
})
|
||||
|
||||
it('keeps the static model when the persisted selector is null', () => {
|
||||
// A DSL exported from an older/AI-generated workflow can persist `model_selector: null`
|
||||
// instead of omitting the key; this must not crash the same way `undefined` doesn't.
|
||||
const selector = null as unknown as ValueSelector
|
||||
|
||||
expect(isEnvironmentModelSource(selector)).toBe(false)
|
||||
expect(resolveLLMNodeModel(model, selector, environmentVariables)).toBe(model)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -24,7 +24,7 @@ const isLLMEnvironmentVariableValue = (value: unknown): value is LLMEnvironmentV
|
||||
}
|
||||
|
||||
export const isEnvironmentModelSource = (modelSelector: ValueSelector | undefined) =>
|
||||
modelSelector !== undefined && (modelSelector.length === 0 || modelSelector[0] === 'env')
|
||||
modelSelector != null && (modelSelector.length === 0 || modelSelector[0] === 'env')
|
||||
|
||||
export const getLLMEnvironmentModel = (
|
||||
modelSelector: ValueSelector | undefined,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user