From 7527bcfb9d17c5c4457f0c764ab60c0cf0cbd8b2 Mon Sep 17 00:00:00 2001 From: Aadesh Kheria Date: Tue, 5 May 2026 13:19:25 -0700 Subject: [PATCH] Enhance occurrenceIndex validation in applyDashboardPatches to ensure it is a valid integer and within bounds --- apps/dashboard/src/components/vibe-coding/chat-adapters.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/dashboard/src/components/vibe-coding/chat-adapters.ts b/apps/dashboard/src/components/vibe-coding/chat-adapters.ts index 464a46f7c..a98e8d662 100644 --- a/apps/dashboard/src/components/vibe-coding/chat-adapters.ts +++ b/apps/dashboard/src/components/vibe-coding/chat-adapters.ts @@ -98,7 +98,11 @@ export function applyDashboardPatches(source: string, edits: DashboardPatchEdit[ let chosenIndex: number; if (edit.occurrenceIndex != null) { - if (edit.occurrenceIndex < 0 || edit.occurrenceIndex >= matches.length) { + if ( + !Number.isInteger(edit.occurrenceIndex) + || edit.occurrenceIndex < 0 + || edit.occurrenceIndex >= matches.length + ) { failures.push({ index, reason: "not-found", oldTextPreview: preview }); return; }