debug: log full Ivanti search response to diagnose UUID resolution

This commit is contained in:
jramos
2026-04-13 13:10:31 -06:00
parent 5469a86e6e
commit 4578f8cd85

View File

@@ -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) {
// 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));
}
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;
} 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);