Fix requeue inserting Postgres array literal instead of JSON into cves_json

This commit is contained in:
Jordan Ramos
2026-05-15 17:41:38 -06:00
parent be1d357692
commit 3643c123b4

View File

@@ -1031,10 +1031,13 @@ function createIvantiFpWorkflowRouter() {
// use finding_ids_json to look up finding data from ivanti_findings
if (findingsToQueue.length === 0 && findingIds.length > 0) {
const { rows: findings } = await pool.query(
`SELECT id AS finding_id, title AS finding_title, cves AS cves_json, ip_address, host_name AS hostname FROM ivanti_findings WHERE id = ANY($1)`,
`SELECT id AS finding_id, title AS finding_title, cves, ip_address, host_name AS hostname FROM ivanti_findings WHERE id = ANY($1)`,
[findingIds.map(String)]
);
findingsToQueue = findings;
findingsToQueue = findings.map(f => ({
...f,
cves_json: Array.isArray(f.cves) ? JSON.stringify(f.cves) : null,
}));
// Last resort: create items with just the finding IDs (minimal data)
if (findingsToQueue.length === 0) {