Merge pull request #10140 from continuedev/dallin/single-block-yaml-failure
fix: don't crash config loading for one block failure
This commit is contained in:
commit
82b606c390
1 changed files with 23 additions and 20 deletions
|
|
@ -1,9 +1,9 @@
|
|||
import {
|
||||
AssistantUnrolled,
|
||||
AssistantUnrolledNonNullable,
|
||||
BLOCK_TYPES,
|
||||
ConfigResult,
|
||||
ConfigValidationError,
|
||||
isAssistantUnrolledNonNullable,
|
||||
mergeConfigYamlRequestOptions,
|
||||
mergeUnrolledAssistants,
|
||||
ModelRole,
|
||||
|
|
@ -145,8 +145,8 @@ async function loadConfigYaml(options: {
|
|||
}
|
||||
}
|
||||
|
||||
if (config && isAssistantUnrolledNonNullable(config)) {
|
||||
errors.push(...validateConfigYaml(config));
|
||||
if (config) {
|
||||
errors.push(...validateConfigYaml(nonNullifyConfigYaml(config)));
|
||||
}
|
||||
|
||||
if (errors?.some((error) => error.fatal)) {
|
||||
|
|
@ -165,15 +165,30 @@ async function loadConfigYaml(options: {
|
|||
};
|
||||
}
|
||||
|
||||
function nonNullifyConfigYaml(
|
||||
unrolledAssistant: AssistantUnrolled,
|
||||
): AssistantUnrolledNonNullable {
|
||||
return {
|
||||
...unrolledAssistant,
|
||||
data: unrolledAssistant.data?.filter((k) => !!k),
|
||||
context: unrolledAssistant.context?.filter((k) => !!k),
|
||||
docs: unrolledAssistant.docs?.filter((k) => !!k),
|
||||
mcpServers: unrolledAssistant.mcpServers?.filter((k) => !!k),
|
||||
models: unrolledAssistant.models?.filter((k) => !!k),
|
||||
prompts: unrolledAssistant.prompts?.filter((k) => !!k),
|
||||
rules: unrolledAssistant.rules?.filter((k) => !!k).map((k) => k!),
|
||||
};
|
||||
}
|
||||
|
||||
export async function configYamlToContinueConfig(options: {
|
||||
config: AssistantUnrolled;
|
||||
unrolledAssistant: AssistantUnrolled;
|
||||
ide: IDE;
|
||||
ideInfo: IdeInfo;
|
||||
uniqueId: string;
|
||||
llmLogger: ILLMLogger;
|
||||
workOsAccessToken: string | undefined;
|
||||
}): Promise<{ config: ContinueConfig; errors: ConfigValidationError[] }> {
|
||||
let { config, ide, ideInfo, uniqueId, llmLogger } = options;
|
||||
let { unrolledAssistant, ide, ideInfo, uniqueId, llmLogger } = options;
|
||||
|
||||
const localErrors: ConfigValidationError[] = [];
|
||||
|
||||
|
|
@ -203,22 +218,10 @@ export async function configYamlToContinueConfig(options: {
|
|||
subagent: null,
|
||||
},
|
||||
rules: [],
|
||||
requestOptions: { ...config.requestOptions },
|
||||
requestOptions: { ...unrolledAssistant.requestOptions },
|
||||
};
|
||||
|
||||
// Right now, if there are any missing packages in the config, then we will just throw an error
|
||||
if (!isAssistantUnrolledNonNullable(config)) {
|
||||
return {
|
||||
config: continueConfig,
|
||||
errors: [
|
||||
{
|
||||
message:
|
||||
"Failed to load config due to missing blocks, see which blocks are missing below",
|
||||
fatal: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
const config = nonNullifyConfigYaml(unrolledAssistant);
|
||||
|
||||
for (const rule of config.rules ?? []) {
|
||||
const convertedRule = convertYamlRuleToContinueRule(rule);
|
||||
|
|
@ -447,7 +450,7 @@ export async function loadContinueConfigFromYaml(options: {
|
|||
|
||||
const { config: continueConfig, errors: localErrors } =
|
||||
await configYamlToContinueConfig({
|
||||
config: configYamlResult.config,
|
||||
unrolledAssistant: configYamlResult.config,
|
||||
ide,
|
||||
ideInfo,
|
||||
uniqueId,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue