From 3b391ec54cfc08471332b0f739e339b9d3a494ad Mon Sep 17 00:00:00 2001 From: ajmallesh Date: Tue, 13 Jan 2026 13:13:27 -0800 Subject: [PATCH] fix: re-throw retryable errors in checkExploitationQueue --- src/temporal/activities.ts | 46 +++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/src/temporal/activities.ts b/src/temporal/activities.ts index abe763d..edbe8f7 100644 --- a/src/temporal/activities.ts +++ b/src/temporal/activities.ts @@ -57,7 +57,7 @@ import { loadPrompt } from '../prompts/prompt-manager.js'; import { parseConfig, distributeConfig } from '../config-parser.js'; import { classifyErrorForTemporal } from '../error-handling.js'; import { - validateQueueAndDeliverable, + safeValidateQueueAndDeliverable, type VulnType, type ExploitationDecision, } from '../queue-validation.js'; @@ -354,6 +354,10 @@ export async function assembleReportActivity(input: ActivityInput): Promise { const { repoPath } = input; - try { - const decision = await validateQueueAndDeliverable(vulnType, repoPath); + const result = await safeValidateQueueAndDeliverable(vulnType, repoPath); + + if (result.success && result.data) { + const { shouldExploit, vulnerabilityCount } = result.data; console.log( chalk.blue( - `🔍 ${vulnType}: ${decision.shouldExploit ? `${decision.vulnerabilityCount} vulnerabilities found` : 'no vulnerabilities, skipping exploitation'}` + `🔍 ${vulnType}: ${shouldExploit ? `${vulnerabilityCount} vulnerabilities found` : 'no vulnerabilities, skipping exploitation'}` ) ); - return decision; - } catch (error) { - // If validation fails (missing files, invalid JSON), log and skip exploitation - // This is safer than crashing - the vuln agent likely failed or found nothing - const errMsg = error instanceof Error ? error.message : String(error); - console.log(chalk.yellow(`⚠️ ${vulnType}: Queue validation failed (${errMsg}), skipping exploitation`)); - return { - shouldExploit: false, - shouldRetry: false, - vulnerabilityCount: 0, - vulnType, - }; + return result.data; } + + // Validation failed - check if we should retry or skip + const error = result.error; + if (error?.retryable) { + // Re-throw retryable errors so Temporal can retry the vuln agent + console.log(chalk.yellow(`⚠️ ${vulnType}: ${error.message} (retrying)`)); + throw error; + } + + // Non-retryable error - skip exploitation gracefully + console.log( + chalk.yellow(`⚠️ ${vulnType}: ${error?.message ?? 'Unknown error'}, skipping exploitation`) + ); + return { + shouldExploit: false, + shouldRetry: false, + vulnerabilityCount: 0, + vulnType, + }; }