mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 06:11:11 -05:00
Update idempotency key handling in edge functions
Read idempotency key from headers in process-selective-approval and process-selective-rejection, remove it from request bodies, add header validation, and redeploy edge functions to fix idempotency flow.
This commit is contained in:
@@ -45,7 +45,6 @@ console.log('Edge function initialized successfully', {
|
||||
interface ApprovalRequest {
|
||||
submissionId: string;
|
||||
itemIds: string[];
|
||||
idempotencyKey: string;
|
||||
}
|
||||
|
||||
// Main handler function
|
||||
@@ -144,7 +143,22 @@ const handler = async (req: Request) => {
|
||||
// STEP 2: Parse request
|
||||
addSpanEvent(rootSpan, 'validation_start');
|
||||
const body: ApprovalRequest = await req.json();
|
||||
const { submissionId, itemIds, idempotencyKey } = body;
|
||||
const { submissionId, itemIds } = body;
|
||||
const idempotencyKey = req.headers.get('x-idempotency-key');
|
||||
|
||||
if (!idempotencyKey) {
|
||||
addSpanEvent(rootSpan, 'validation_failed', { reason: 'missing_idempotency_key' });
|
||||
edgeLogger.warn('Missing idempotency key', { requestId });
|
||||
endSpan(rootSpan, 'error');
|
||||
logSpan(rootSpan);
|
||||
return new Response(
|
||||
JSON.stringify({ error: 'Missing X-Idempotency-Key header' }),
|
||||
{
|
||||
status: 400,
|
||||
headers: { ...corsHeaders, 'Content-Type': 'application/json' }
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (!submissionId || !itemIds || itemIds.length === 0) {
|
||||
addSpanEvent(rootSpan, 'validation_failed', {
|
||||
|
||||
Reference in New Issue
Block a user