fix(config): warn on ignored legacy config keys

This commit is contained in:
2026-04-21 13:10:55 +00:00
parent c95961d596
commit 1f24df0d80
2 changed files with 108 additions and 0 deletions
+37
View File
@@ -1,6 +1,7 @@
import * as fs from 'node:fs/promises';
import { PATHS, VERSION } from '../constants.ts';
import type { IModelGridConfig } from '../interfaces/config.ts';
import { logger } from '../logger.ts';
export class ConfigManager {
public async loadConfig(): Promise<IModelGridConfig> {
@@ -21,6 +22,8 @@ export class ConfigManager {
}
public normalizeConfig(config: Partial<IModelGridConfig>): IModelGridConfig {
this.logIgnoredConfigKeys(config);
const filteredContainers = (config.containers || []).filter(
(container) => (container as { type?: string }).type !== 'ollama',
);
@@ -72,4 +75,38 @@ export class ConfigManager {
checkInterval: config.checkInterval || 30000,
};
}
private logIgnoredConfigKeys(config: Partial<IModelGridConfig>): void {
const unknownTopLevelKeys = Object.keys(config).filter((key) =>
!['version', 'api', 'ui', 'docker', 'gpus', 'containers', 'models', 'cluster', 'checkInterval']
.includes(key)
);
for (const key of unknownTopLevelKeys) {
logger.warn(`Ignoring unknown config key: ${key}`);
}
const legacyModelConfig = config.models as {
greenlistUrl?: string;
autoPull?: boolean;
defaultContainer?: string;
} | undefined;
if (legacyModelConfig?.greenlistUrl) {
logger.warn('Ignoring removed config key: models.greenlistUrl');
}
if (legacyModelConfig?.autoPull !== undefined) {
logger.warn('Ignoring removed config key: models.autoPull');
}
if (legacyModelConfig?.defaultContainer) {
logger.warn('Ignoring removed config key: models.defaultContainer');
}
for (const container of config.containers || []) {
const containerType = (container as { type?: string }).type;
if (containerType === 'ollama') {
logger.warn('Ignoring unsupported container type: ollama');
}
}
}
}