From 4578f8cd85a000905c573407ebcff4b9bb67b2d9 Mon Sep 17 00:00:00 2001 From: jramos Date: Mon, 13 Apr 2026 13:10:31 -0600 Subject: [PATCH] debug: log full Ivanti search response to diagnose UUID resolution --- backend/routes/ivantiFpWorkflow.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/backend/routes/ivantiFpWorkflow.js b/backend/routes/ivantiFpWorkflow.js index 7429fdb..f02cc71 100644 --- a/backend/routes/ivantiFpWorkflow.js +++ b/backend/routes/ivantiFpWorkflow.js @@ -163,9 +163,12 @@ async function resolveWorkflowBatchUuid(db, submission, apiKey, clientId, skipTl // Search Ivanti for the workflow batch by numeric ID to get the UUID const searchUrl = `/client/${encodeURIComponent(clientId)}/workflowBatch/search`; + const batchId = String(submission.ivanti_workflow_batch_id); + + // Try searching by 'id' field with 'internal' projection (matches existing sync pattern) const searchBody = { - filters: [{ field: 'id', exclusive: false, operator: 'EXACT', value: String(submission.ivanti_workflow_batch_id) }], - projection: 'basic', + filters: [{ field: 'id', exclusive: false, operator: 'EXACT', value: batchId }], + projection: 'internal', sort: [{ field: 'id', direction: 'ASC' }], page: 0, size: 1 @@ -179,8 +182,10 @@ async function resolveWorkflowBatchUuid(db, submission, apiKey, clientId, skipTl return null; } + console.log('[resolveUUID] Search status:', result.status, 'for batch ID:', batchId); + console.log('[resolveUUID] Response body (first 1000 chars):', (result.body || '').substring(0, 1000)); + if (result.status !== 200) { - console.error('[resolveUUID] Search returned status:', result.status, result.body?.substring(0, 200)); return null; } @@ -195,17 +200,19 @@ async function resolveWorkflowBatchUuid(db, submission, apiKey, clientId, skipTl else if (data.data) batches = data.data; else if (Array.isArray(data)) batches = data; + console.log('[resolveUUID] Found', batches.length, 'batches'); + const batch = batches[0]; if (batch) { + // Log all keys so we can identify the right field + console.log('[resolveUUID] Batch keys:', Object.keys(batch).join(', ')); + console.log('[resolveUUID] Batch sample:', JSON.stringify(batch).substring(0, 800)); // Try common UUID field names uuid = batch.uuid || batch.workflowBatchUuid || batch.batchUuid || batch.groupUuid || null; - if (!uuid) { - // Log all keys so we can identify the right field - console.log('[resolveUUID] Batch keys:', Object.keys(batch).join(', ')); - console.log('[resolveUUID] Batch sample:', JSON.stringify(batch).substring(0, 500)); - } } else { - console.log('[resolveUUID] No batches found for ID:', submission.ivanti_workflow_batch_id); + console.log('[resolveUUID] No batches found for ID:', batchId); + // Log the full response structure to understand the format + console.log('[resolveUUID] Response keys:', Object.keys(data).join(', ')); } } catch (e) { console.error('[resolveUUID] Failed to parse search response:', e.message);