MCPcopy Create free account
hub / github.com/langgenius/dify / loadConfig

Function loadConfig

cli/src/config/config-loader.ts:11–42  ·  view source on GitHub ↗
(store: YamlStore)

Source from the content-addressed store, hash-verified

9 | { found: true, config: ConfigFile }
10
11export async function loadConfig(store: YamlStore): Promise<LoadResult> {
12 let raw: Record<string, unknown> | null
13 try {
14 raw = await store.getTyped<Record<string, unknown>>()
15 }
16 catch (err) {
17 throw newError(
18 ErrorCode.ConfigSchemaUnsupported,
19 `parse config.yml: ${(err as Error).message}`,
20 ).wrap(err).withHint('config.yml is not valid YAML')
21 }
22
23 if (raw === null)
24 return { found: false }
25
26 const result = ConfigFileSchema.safeParse(raw)
27 if (!result.success) {
28 throw newError(
29 ErrorCode.ConfigSchemaUnsupported,
30 `validate config.yml: ${result.error.issues.map(i => i.message).join('; ')}`,
31 ).withHint('config.yml does not match the v1 schema')
32 }
33
34 if (result.data.schema_version > CURRENT_SCHEMA_VERSION) {
35 throw newError(
36 ErrorCode.ConfigSchemaUnsupported,
37 `config.yml schema_version=${result.data.schema_version} is newer than this binary supports (max=${CURRENT_SCHEMA_VERSION})`,
38 ).withHint('upgrade difyctl, or remove config.yml')
39 }
40
41 return { found: true, config: result.data }
42}

Callers 10

runConfigGetFunction · 0.90
runConfigUnsetFunction · 0.90
run.test.tsFile · 0.90
runConfigViewFunction · 0.90
runConfigSetFunction · 0.90
run.test.tsFile · 0.90
loadDevProxyConfigFunction · 0.85
enqueueReloadFunction · 0.85

Calls 5

newErrorFunction · 0.90
withHintMethod · 0.80
wrapMethod · 0.45
joinMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected