From d58fa8be2a40ee410cc8f8adae45d94c481e379d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 17 Jan 2026 22:45:45 +0000 Subject: [PATCH] Add safety checks to compute functions and schema loader Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com> --- src/schemas/compute-functions.ts | 4 ++-- src/schemas/schema-loader.ts | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/schemas/compute-functions.ts b/src/schemas/compute-functions.ts index f34056e..6cf5b07 100644 --- a/src/schemas/compute-functions.ts +++ b/src/schemas/compute-functions.ts @@ -25,9 +25,9 @@ export const computeAddTodo = (data: any) => ({ completed: false, }) -export const updateFilterQuery = (_: any, event: any) => event.target.value +export const updateFilterQuery = (_: any, event: any) => event?.target?.value || '' -export const updateNewTodo = (data: any, event: any) => event.target.value +export const updateNewTodo = (data: any, event: any) => event?.target?.value || '' export const checkCanAddTodo = (data: any) => data.newTodo?.trim().length > 0 diff --git a/src/schemas/schema-loader.ts b/src/schemas/schema-loader.ts index 1ef5cf4..085ff98 100644 --- a/src/schemas/schema-loader.ts +++ b/src/schemas/schema-loader.ts @@ -4,6 +4,15 @@ import * as computeFunctions from './compute-functions' type ComputeFunctionMap = typeof computeFunctions export function hydrateSchema(jsonSchema: any): PageSchema { + // Validate basic schema structure + if (!jsonSchema || typeof jsonSchema !== 'object') { + throw new Error('Invalid schema: expected an object') + } + + if (!jsonSchema.id || !jsonSchema.name) { + console.warn('Schema missing required fields: id and name') + } + const schema = { ...jsonSchema } if (schema.dataSources) {