mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 08:17:11 +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 {
|
||||
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
|
||||
if (typeof value === 'string') {
|
||||
const normalizedValue = value.toLowerCase().trim();
|
||||
@@ -198,6 +207,15 @@ function validateBudgetThinking(
|
||||
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
|
||||
if (budget < THINKING_BUDGET_MIN) {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user