Add safety checks to compute functions and schema loader

Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-17 22:45:45 +00:00
parent 05c1e2d789
commit d58fa8be2a
2 changed files with 11 additions and 2 deletions

View File

@@ -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

View File

@@ -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) {