debug: log full Ivanti search response to diagnose UUID resolution
This commit is contained in:
@@ -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
|
// Search Ivanti for the workflow batch by numeric ID to get the UUID
|
||||||
const searchUrl = `/client/${encodeURIComponent(clientId)}/workflowBatch/search`;
|
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 = {
|
const searchBody = {
|
||||||
filters: [{ field: 'id', exclusive: false, operator: 'EXACT', value: String(submission.ivanti_workflow_batch_id) }],
|
filters: [{ field: 'id', exclusive: false, operator: 'EXACT', value: batchId }],
|
||||||
projection: 'basic',
|
projection: 'internal',
|
||||||
sort: [{ field: 'id', direction: 'ASC' }],
|
sort: [{ field: 'id', direction: 'ASC' }],
|
||||||
page: 0,
|
page: 0,
|
||||||
size: 1
|
size: 1
|
||||||
@@ -179,8 +182,10 @@ async function resolveWorkflowBatchUuid(db, submission, apiKey, clientId, skipTl
|
|||||||
return null;
|
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) {
|
if (result.status !== 200) {
|
||||||
console.error('[resolveUUID] Search returned status:', result.status, result.body?.substring(0, 200));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,17 +200,19 @@ async function resolveWorkflowBatchUuid(db, submission, apiKey, clientId, skipTl
|
|||||||
else if (data.data) batches = data.data;
|
else if (data.data) batches = data.data;
|
||||||
else if (Array.isArray(data)) batches = data;
|
else if (Array.isArray(data)) batches = data;
|
||||||
|
|
||||||
|
console.log('[resolveUUID] Found', batches.length, 'batches');
|
||||||
|
|
||||||
const batch = batches[0];
|
const batch = batches[0];
|
||||||
if (batch) {
|
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
|
// Log all keys so we can identify the right field
|
||||||
console.log('[resolveUUID] Batch keys:', Object.keys(batch).join(', '));
|
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 {
|
} 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) {
|
} catch (e) {
|
||||||
console.error('[resolveUUID] Failed to parse search response:', e.message);
|
console.error('[resolveUUID] Failed to parse search response:', e.message);
|
||||||
|
|||||||
Reference in New Issue
Block a user