mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-28 21:06:59 -05:00
feat: Implement comprehensive validation error handling
This commit is contained in:
@@ -247,28 +247,68 @@ export function SubmissionReviewManager({
|
||||
}
|
||||
|
||||
// Run validation on all selected items
|
||||
const validationResultsMap = await validateMultipleItems(
|
||||
selectedItems.map(item => ({
|
||||
item_type: item.item_type,
|
||||
item_data: item.item_data,
|
||||
id: item.id
|
||||
}))
|
||||
);
|
||||
let validationResultsMap: Map<string, any>;
|
||||
|
||||
setValidationResults(validationResultsMap);
|
||||
|
||||
// Check for blocking errors
|
||||
const itemsWithBlockingErrors = selectedItems.filter(item => {
|
||||
const result = validationResultsMap.get(item.id);
|
||||
return result && result.blockingErrors.length > 0;
|
||||
});
|
||||
|
||||
// CRITICAL: Blocking errors can NEVER be bypassed, regardless of warnings
|
||||
if (itemsWithBlockingErrors.length > 0) {
|
||||
setHasBlockingErrors(true);
|
||||
setShowValidationBlockerDialog(true);
|
||||
dispatch({ type: 'ERROR', payload: { error: 'Validation failed' } });
|
||||
return; // Block approval
|
||||
try {
|
||||
validationResultsMap = await validateMultipleItems(
|
||||
selectedItems.map(item => ({
|
||||
item_type: item.item_type,
|
||||
item_data: item.item_data,
|
||||
id: item.id
|
||||
}))
|
||||
);
|
||||
|
||||
setValidationResults(validationResultsMap);
|
||||
|
||||
// Check for blocking errors
|
||||
const itemsWithBlockingErrors = selectedItems.filter(item => {
|
||||
const result = validationResultsMap.get(item.id);
|
||||
return result && result.blockingErrors.length > 0;
|
||||
});
|
||||
|
||||
// CRITICAL: Blocking errors can NEVER be bypassed, regardless of warnings
|
||||
if (itemsWithBlockingErrors.length > 0) {
|
||||
// Log which items have blocking errors
|
||||
itemsWithBlockingErrors.forEach(item => {
|
||||
const result = validationResultsMap.get(item.id);
|
||||
logger.error('Blocking validation errors prevent approval', {
|
||||
submissionId,
|
||||
itemId: item.id,
|
||||
itemType: item.item_type,
|
||||
errors: result?.blockingErrors
|
||||
});
|
||||
});
|
||||
|
||||
setHasBlockingErrors(true);
|
||||
setShowValidationBlockerDialog(true);
|
||||
dispatch({ type: 'ERROR', payload: { error: 'Validation failed' } });
|
||||
return; // Block approval
|
||||
}
|
||||
} catch (error) {
|
||||
// Validation itself failed (network error, bug, etc.)
|
||||
const errorId = handleError(error, {
|
||||
action: 'Validation System Error',
|
||||
userId: user?.id,
|
||||
metadata: {
|
||||
submissionId,
|
||||
selectedItemCount: selectedItems.length,
|
||||
itemTypes: selectedItems.map(i => i.item_type)
|
||||
}
|
||||
});
|
||||
|
||||
toast({
|
||||
title: 'Validation System Error',
|
||||
description: (
|
||||
<div className="space-y-2">
|
||||
<p>Unable to validate submission. Please try again.</p>
|
||||
<p className="text-xs font-mono">Ref: {errorId.slice(0, 8)}</p>
|
||||
</div>
|
||||
),
|
||||
variant: 'destructive'
|
||||
});
|
||||
|
||||
dispatch({ type: 'ERROR', payload: { error: 'Validation system error' } });
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for warnings
|
||||
|
||||
Reference in New Issue
Block a user