From 53a576670e26b45f53dbca479e772b05cafdfde8 Mon Sep 17 00:00:00 2001 From: Bas van den Aakster Date: Fri, 12 Dec 2025 22:53:29 +0100 Subject: [PATCH] Add candidate validation to addIceCandidates() Validation: Add basic candidate validation - Validate each candidate is an object - Don't enforce specific structure (per CLAUDE.md guidelines) - Provides clear error messages with index Impact: Prevents runtime errors from null/primitive values Note: Intentionally keeps candidate structure flexible per design --- src/rpc.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/rpc.ts b/src/rpc.ts index 5f0e2cd..3b4b1e4 100644 --- a/src/rpc.ts +++ b/src/rpc.ts @@ -600,6 +600,13 @@ const handlers: Record = { throw new Error('Missing or invalid required parameter: candidates'); } + // Validate each candidate is an object (don't enforce structure per CLAUDE.md) + candidates.forEach((candidate, index) => { + if (!candidate || typeof candidate !== 'object') { + throw new Error(`Invalid candidate at index ${index}: must be an object`); + } + }); + const offer = await storage.getOfferById(offerId); if (!offer) { throw new Error('Offer not found');