mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-13 14:15:56 +00:00
fix(cliproxy): address code review feedback (attempt 2/5)
- Add tiers shape validation in variant-routes POST/PUT endpoints - Use process.exit(1) for blocked --config on composite variants
This commit is contained in:
1 parent
854b198b64
commit
ac574e0baf
2 files changed
+35
-1
No files matched your search
@@ -432,10 +432,12 @@ export async function execClaudeWithCLIProxy(
|
|||||||
console.log(
|
console.log(
|
||||||
warn('Composite variants use per-tier config. Edit config.yaml to change tier models.')
|
warn('Composite variants use per-tier config. Edit config.yaml to change tier models.')
|
||||||
);
|
);
|
||||||
|
console.error(` Use "ccs cliproxy edit ${provider}" to modify composite variants`);
|
||||||
|
process.exit(1);
|
||||||
} else {
|
} else {
|
||||||
await configureProviderModel(provider, true, cfg.customSettingsPath);
|
await configureProviderModel(provider, true, cfg.customSettingsPath);
|
||||||
|
process.exit(0);
|
||||||
}
|
}
|
||||||
process.exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle --logout
|
// Handle --logout
|
||||||
|
|||||||
@@ -75,6 +75,21 @@ router.post('/', (req: Request, res: Response): void => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate tiers shape
|
||||||
|
const requiredTiers = ['opus', 'sonnet', 'haiku'] as const;
|
||||||
|
for (const tier of requiredTiers) {
|
||||||
|
if (
|
||||||
|
!tiers[tier] ||
|
||||||
|
typeof tiers[tier].provider !== 'string' ||
|
||||||
|
typeof tiers[tier].model !== 'string'
|
||||||
|
) {
|
||||||
|
res.status(400).json({
|
||||||
|
error: `Invalid tier config for '${tier}': requires 'provider' and 'model' strings`,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const result = createCompositeVariant({ name, defaultTier: default_tier, tiers });
|
const result = createCompositeVariant({ name, defaultTier: default_tier, tiers });
|
||||||
|
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
@@ -147,6 +162,23 @@ router.put('/:name', (req: Request, res: Response): void => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate tiers shape if provided
|
||||||
|
if (tiers) {
|
||||||
|
const requiredTiers = ['opus', 'sonnet', 'haiku'] as const;
|
||||||
|
for (const tier of requiredTiers) {
|
||||||
|
if (
|
||||||
|
!tiers[tier] ||
|
||||||
|
typeof tiers[tier].provider !== 'string' ||
|
||||||
|
typeof tiers[tier].model !== 'string'
|
||||||
|
) {
|
||||||
|
res.status(400).json({
|
||||||
|
error: `Invalid tier config for '${tier}': requires 'provider' and 'model' strings`,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const result = updateCompositeVariant(name, { defaultTier: default_tier, tiers });
|
const result = updateCompositeVariant(name, { defaultTier: default_tier, tiers });
|
||||||
|
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
|||||||
Reference in new issue
Block a user