mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 09:11:12 -05:00
feat: Implement emergency hotfixes
This commit is contained in:
@@ -1,6 +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";
|
||||
import { validateEntityData, validateEntityDataStrict } from "./validation.ts";
|
||||
|
||||
const corsHeaders = {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
@@ -206,10 +206,28 @@ 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(', ')}`);
|
||||
// Validate entity data with strict validation
|
||||
const validation = validateEntityDataStrict(item.item_type, item.item_data);
|
||||
|
||||
if (validation.blockingErrors.length > 0) {
|
||||
console.error(`❌ Blocking errors for item ${item.id}:`, validation.blockingErrors);
|
||||
|
||||
// Fail the entire batch if ANY item has blocking errors
|
||||
return new Response(JSON.stringify({
|
||||
success: false,
|
||||
message: 'Validation failed: Items have blocking errors that must be fixed',
|
||||
errors: validation.blockingErrors,
|
||||
failedItemId: item.id,
|
||||
failedItemType: item.item_type
|
||||
}), {
|
||||
status: 400,
|
||||
headers: { ...corsHeaders, 'Content-Type': 'application/json' }
|
||||
});
|
||||
}
|
||||
|
||||
if (validation.warnings.length > 0) {
|
||||
console.warn(`⚠️ Warnings for item ${item.id}:`, validation.warnings);
|
||||
// Continue processing - warnings don't block approval
|
||||
}
|
||||
|
||||
// Set user context for versioning trigger
|
||||
|
||||
Reference in New Issue
Block a user