Skip to content

Commit 53dee49

Browse files
committed
Merge pull request #381 from misterdas/fix/critical-bugs-and-improvements
fix: critical bugs and error handling improvements
1 parent 302e901 commit 53dee49

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

lib/config.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,13 @@ export function validateConfigTypes(config: Record<string, any>): ValidationErro
220220
actual: typeof config.turnProtection.turns,
221221
})
222222
}
223+
if (typeof config.turnProtection.turns === "number" && config.turnProtection.turns < 1) {
224+
errors.push({
225+
key: "turnProtection.turns",
226+
expected: "positive number (>= 1)",
227+
actual: `${config.turnProtection.turns}`,
228+
})
229+
}
223230
}
224231

225232
const commands = config.commands
@@ -292,6 +299,16 @@ export function validateConfigTypes(config: Record<string, any>): ValidationErro
292299
})
293300
}
294301

302+
if (
303+
typeof tools.settings.nudgeFrequency === "number" &&
304+
tools.settings.nudgeFrequency < 1
305+
) {
306+
errors.push({
307+
key: "tools.settings.nudgeFrequency",
308+
expected: "positive number (>= 1)",
309+
actual: `${tools.settings.nudgeFrequency} (will be clamped to 1)`,
310+
})
311+
}
295312
if (
296313
tools.settings.protectedTools !== undefined &&
297314
!Array.isArray(tools.settings.protectedTools)
@@ -433,7 +450,17 @@ export function validateConfigTypes(config: Record<string, any>): ValidationErro
433450
actual: typeof strategies.purgeErrors.turns,
434451
})
435452
}
436-
453+
// Warn if turns is 0 or negative - will be clamped to 1
454+
if (
455+
typeof strategies.purgeErrors.turns === "number" &&
456+
strategies.purgeErrors.turns < 1
457+
) {
458+
errors.push({
459+
key: "strategies.purgeErrors.turns",
460+
expected: "positive number (>= 1)",
461+
actual: `${strategies.purgeErrors.turns} (will be clamped to 1)`,
462+
})
463+
}
437464
if (
438465
strategies.purgeErrors.protectedTools !== undefined &&
439466
!Array.isArray(strategies.purgeErrors.protectedTools)

lib/strategies/purge-errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const purgeErrors = (
3939
}
4040

4141
const protectedTools = config.strategies.purgeErrors.protectedTools
42-
const turnThreshold = config.strategies.purgeErrors.turns
42+
const turnThreshold = Math.max(1, config.strategies.purgeErrors.turns)
4343

4444
const newPruneIds: string[] = []
4545

0 commit comments

Comments
 (0)