mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-29 14:34:55 -07:00
Make schema validation errors non-fatal (#15487)
This commit is contained in:
@@ -233,6 +233,7 @@ export interface SessionRetentionSettings {
|
||||
export interface SettingsError {
|
||||
message: string;
|
||||
path: string;
|
||||
severity: 'error' | 'warning';
|
||||
}
|
||||
|
||||
export interface SettingsFile {
|
||||
@@ -456,6 +457,7 @@ export class LoadedSettings {
|
||||
workspace: SettingsFile,
|
||||
isTrusted: boolean,
|
||||
migratedInMemoryScopes: Set<SettingScope>,
|
||||
errors: SettingsError[] = [],
|
||||
) {
|
||||
this.system = system;
|
||||
this.systemDefaults = systemDefaults;
|
||||
@@ -463,6 +465,7 @@ export class LoadedSettings {
|
||||
this.workspace = workspace;
|
||||
this.isTrusted = isTrusted;
|
||||
this.migratedInMemoryScopes = migratedInMemoryScopes;
|
||||
this.errors = errors;
|
||||
this._merged = this.computeMergedSettings();
|
||||
}
|
||||
|
||||
@@ -472,6 +475,7 @@ export class LoadedSettings {
|
||||
readonly workspace: SettingsFile;
|
||||
readonly isTrusted: boolean;
|
||||
readonly migratedInMemoryScopes: Set<SettingScope>;
|
||||
readonly errors: SettingsError[];
|
||||
|
||||
private _merged: Settings;
|
||||
|
||||
@@ -658,6 +662,7 @@ export function loadSettings(
|
||||
settingsErrors.push({
|
||||
message: 'Settings file is not a valid JSON object.',
|
||||
path: filePath,
|
||||
severity: 'error',
|
||||
});
|
||||
return { settings: {} };
|
||||
}
|
||||
@@ -695,19 +700,20 @@ export function loadSettings(
|
||||
validationResult.error,
|
||||
filePath,
|
||||
);
|
||||
throw new FatalConfigError(errorMessage);
|
||||
settingsErrors.push({
|
||||
message: errorMessage,
|
||||
path: filePath,
|
||||
severity: 'warning',
|
||||
});
|
||||
}
|
||||
|
||||
return { settings: settingsObject as Settings, rawJson: content };
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
// Preserve FatalConfigError with formatted validation messages
|
||||
if (error instanceof FatalConfigError) {
|
||||
throw error;
|
||||
}
|
||||
settingsErrors.push({
|
||||
message: getErrorMessage(error),
|
||||
path: filePath,
|
||||
severity: 'error',
|
||||
});
|
||||
}
|
||||
return { settings: {} };
|
||||
@@ -779,10 +785,10 @@ export function loadSettings(
|
||||
// the settings to avoid a cycle
|
||||
loadEnvironment(tempMergedSettings);
|
||||
|
||||
// Create LoadedSettings first
|
||||
|
||||
if (settingsErrors.length > 0) {
|
||||
const errorMessages = settingsErrors.map(
|
||||
// Check for any fatal errors before proceeding
|
||||
const fatalErrors = settingsErrors.filter((e) => e.severity === 'error');
|
||||
if (fatalErrors.length > 0) {
|
||||
const errorMessages = fatalErrors.map(
|
||||
(error) => `Error in ${error.path}: ${error.message}`,
|
||||
);
|
||||
throw new FatalConfigError(
|
||||
@@ -817,6 +823,7 @@ export function loadSettings(
|
||||
},
|
||||
isTrusted,
|
||||
migratedInMemoryScopes,
|
||||
settingsErrors,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user