mirror of
https://github.com/tiennm99/ccs.git
synced 2026-09-03 06:18:55 +00:00
fix(cliproxy): add NaN/Infinity and empty string validation
- Add Number.isFinite() check to reject NaN/Infinity budgets - Add explicit empty string handling before level validation
This commit is contained in:
@@ -105,6 +105,15 @@ export function validateThinking(
|
|||||||
): ThinkingValidationResult {
|
): ThinkingValidationResult {
|
||||||
const thinking = getModelThinkingSupport(provider, modelId);
|
const thinking = getModelThinkingSupport(provider, modelId);
|
||||||
|
|
||||||
|
// Handle empty string explicitly
|
||||||
|
if (typeof value === 'string' && value.trim() === '') {
|
||||||
|
return {
|
||||||
|
valid: false,
|
||||||
|
value: 'off',
|
||||||
|
warning: 'Empty thinking value not allowed. Using "off".',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Handle off/none/disabled values
|
// Handle off/none/disabled values
|
||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
const normalizedValue = value.toLowerCase().trim();
|
const normalizedValue = value.toLowerCase().trim();
|
||||||
@@ -198,6 +207,15 @@ function validateBudgetThinking(
|
|||||||
budget = value;
|
budget = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reject NaN/Infinity budgets
|
||||||
|
if (!Number.isFinite(budget)) {
|
||||||
|
return {
|
||||||
|
valid: false,
|
||||||
|
value: min || THINKING_BUDGET_DEFAULT_MIN,
|
||||||
|
warning: `Budget must be a finite number. Using minimum ${min || THINKING_BUDGET_DEFAULT_MIN}.`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Reject negative budgets
|
// Reject negative budgets
|
||||||
if (budget < THINKING_BUDGET_MIN) {
|
if (budget < THINKING_BUDGET_MIN) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user