Skip to content

Commit 82b606c

Browse files
authored
Merge pull request #10140 from continuedev/dallin/single-block-yaml-failure
fix: don't crash config loading for one block failure
2 parents 2feadf8 + 5a5f5f8 commit 82b606c

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

core/config/yaml/loadYaml.ts

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {
22
AssistantUnrolled,
3+
AssistantUnrolledNonNullable,
34
BLOCK_TYPES,
45
ConfigResult,
56
ConfigValidationError,
6-
isAssistantUnrolledNonNullable,
77
mergeConfigYamlRequestOptions,
88
mergeUnrolledAssistants,
99
ModelRole,
@@ -145,8 +145,8 @@ async function loadConfigYaml(options: {
145145
}
146146
}
147147

148-
if (config && isAssistantUnrolledNonNullable(config)) {
149-
errors.push(...validateConfigYaml(config));
148+
if (config) {
149+
errors.push(...validateConfigYaml(nonNullifyConfigYaml(config)));
150150
}
151151

152152
if (errors?.some((error) => error.fatal)) {
@@ -165,15 +165,30 @@ async function loadConfigYaml(options: {
165165
};
166166
}
167167

168+
function nonNullifyConfigYaml(
169+
unrolledAssistant: AssistantUnrolled,
170+
): AssistantUnrolledNonNullable {
171+
return {
172+
...unrolledAssistant,
173+
data: unrolledAssistant.data?.filter((k) => !!k),
174+
context: unrolledAssistant.context?.filter((k) => !!k),
175+
docs: unrolledAssistant.docs?.filter((k) => !!k),
176+
mcpServers: unrolledAssistant.mcpServers?.filter((k) => !!k),
177+
models: unrolledAssistant.models?.filter((k) => !!k),
178+
prompts: unrolledAssistant.prompts?.filter((k) => !!k),
179+
rules: unrolledAssistant.rules?.filter((k) => !!k).map((k) => k!),
180+
};
181+
}
182+
168183
export async function configYamlToContinueConfig(options: {
169-
config: AssistantUnrolled;
184+
unrolledAssistant: AssistantUnrolled;
170185
ide: IDE;
171186
ideInfo: IdeInfo;
172187
uniqueId: string;
173188
llmLogger: ILLMLogger;
174189
workOsAccessToken: string | undefined;
175190
}): Promise<{ config: ContinueConfig; errors: ConfigValidationError[] }> {
176-
let { config, ide, ideInfo, uniqueId, llmLogger } = options;
191+
let { unrolledAssistant, ide, ideInfo, uniqueId, llmLogger } = options;
177192

178193
const localErrors: ConfigValidationError[] = [];
179194

@@ -203,22 +218,10 @@ export async function configYamlToContinueConfig(options: {
203218
subagent: null,
204219
},
205220
rules: [],
206-
requestOptions: { ...config.requestOptions },
221+
requestOptions: { ...unrolledAssistant.requestOptions },
207222
};
208223

209-
// Right now, if there are any missing packages in the config, then we will just throw an error
210-
if (!isAssistantUnrolledNonNullable(config)) {
211-
return {
212-
config: continueConfig,
213-
errors: [
214-
{
215-
message:
216-
"Failed to load config due to missing blocks, see which blocks are missing below",
217-
fatal: true,
218-
},
219-
],
220-
};
221-
}
224+
const config = nonNullifyConfigYaml(unrolledAssistant);
222225

223226
for (const rule of config.rules ?? []) {
224227
const convertedRule = convertYamlRuleToContinueRule(rule);
@@ -447,7 +450,7 @@ export async function loadContinueConfigFromYaml(options: {
447450

448451
const { config: continueConfig, errors: localErrors } =
449452
await configYamlToContinueConfig({
450-
config: configYamlResult.config,
453+
unrolledAssistant: configYamlResult.config,
451454
ide,
452455
ideInfo,
453456
uniqueId,

0 commit comments

Comments
 (0)