Fix: Resolve form validation and type errors

This commit is contained in:
gpt-engineer-app[bot]
2025-10-09 19:46:08 +00:00
parent 8c5cf40ccb
commit 37daceff75
4 changed files with 146 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
import { serve } from "https://deno.land/std@0.190.0/http/server.ts";
import { createClient } from "https://esm.sh/@supabase/supabase-js@2.57.4";
import { validateEntityData } from "./validation.ts";
const corsHeaders = {
'Access-Control-Allow-Origin': '*',
@@ -205,6 +206,12 @@ serve(async (req) => {
try {
console.log(`Processing item ${item.id} of type ${item.item_type}`);
// Validate entity data before processing
const validation = validateEntityData(item.item_type, item.item_data);
if (!validation.valid) {
throw new Error(`Validation failed: ${validation.errors.join(', ')}`);
}
// Set user context for versioning trigger
// This allows auto_create_entity_version() to capture the submitter
const { error: setConfigError } = await supabase.rpc('set_config_value', {