mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-13 04:14:57 +00:00
fix(image-analysis): reject unknown backend mappings
This commit is contained in:
1 parent
d40cc60a1d
commit
665668579d
2 files changed
+67
-3
No files matched your search
@@ -40,6 +40,13 @@ const IMAGE_ANALYSIS_PROVIDER_ALIASES = Object.freeze(
|
||||
)
|
||||
);
|
||||
|
||||
function isConfiguredImageAnalysisBackend(
|
||||
backend: string | null,
|
||||
providerModels: Record<string, string>
|
||||
): backend is string {
|
||||
return Boolean(backend && Object.prototype.hasOwnProperty.call(providerModels, backend));
|
||||
}
|
||||
|
||||
function parseArgs(args: string[]): ImageAnalysisCommandOptions {
|
||||
const options: ImageAnalysisCommandOptions = {
|
||||
enable: hasAnyFlag(args, ['--enable']),
|
||||
@@ -296,7 +303,7 @@ export async function handleConfigImageAnalysisCommand(args: string[]): Promise<
|
||||
options.setFallback,
|
||||
Object.keys(imageConfig.provider_models)
|
||||
);
|
||||
if (!normalizedBackend) {
|
||||
if (!isConfiguredImageAnalysisBackend(normalizedBackend, imageConfig.provider_models)) {
|
||||
console.error(fail(`Invalid fallback backend: ${options.setFallback}`));
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -314,7 +321,7 @@ export async function handleConfigImageAnalysisCommand(args: string[]): Promise<
|
||||
console.error(fail('Profile name cannot be empty'));
|
||||
process.exit(1);
|
||||
}
|
||||
if (!normalizedBackend) {
|
||||
if (!isConfiguredImageAnalysisBackend(normalizedBackend, imageConfig.provider_models)) {
|
||||
console.error(fail(`Invalid backend: ${options.setProfileBackend.backend}`));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user