mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-14 02:15:36 +00:00
fix: reject unsupported image analysis backends (#1387)
* fix: reject unsupported image analysis backends * style: apply prettier formatting
This commit is contained in:
1 parent
4cf840ea0a
commit
b35a23a6e4
2 files changed
+34
No files matched your search
@@ -404,6 +404,9 @@ router.put('/', async (req: Request, res: Response): Promise<void> => {
|
||||
if (!normalizedBackend || normalizedModel.length === 0) {
|
||||
return acc;
|
||||
}
|
||||
if (!knownBackends.has(normalizedBackend)) {
|
||||
throw new Error(`Unsupported provider backend "${backendId}".`);
|
||||
}
|
||||
acc[normalizedBackend] = normalizedModel;
|
||||
return acc;
|
||||
},
|
||||
@@ -470,6 +473,10 @@ router.put('/', async (req: Request, res: Response): Promise<void> => {
|
||||
|
||||
res.json(await buildDashboardPayload());
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.message.startsWith('Unsupported provider backend')) {
|
||||
res.status(400).json({ error: error.message });
|
||||
return;
|
||||
}
|
||||
res.status(500).json({ error: (error as Error).message });
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user