From 4f44b9df701e85486162cf755ee5b811b3640b02 Mon Sep 17 00:00:00 2001 From: tech-sushant Date: Tue, 7 Oct 2025 23:19:29 +0530 Subject: [PATCH] refactor: change testId type from string to number across RCA-related modules --- src/tools/rca-agent-utils/constants.ts | 4 ++-- src/tools/rca-agent-utils/rca-data.ts | 8 ++++---- src/tools/rca-agent-utils/types.ts | 6 +++--- src/tools/rca-agent.ts | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/tools/rca-agent-utils/constants.ts b/src/tools/rca-agent-utils/constants.ts index c7a69c0..5818733 100644 --- a/src/tools/rca-agent-utils/constants.ts +++ b/src/tools/rca-agent-utils/constants.ts @@ -3,10 +3,10 @@ import { TestStatus } from "./types.js"; export const FETCH_RCA_PARAMS = { testId: z - .array(z.string()) + .array(z.number().int()) .max(3) .describe( - "Array of test IDs to fetch RCA data for (maximum 3 IDs). If not provided, use the listTestIds tool get all failed testcases. If more than 3 IDs are provided, only the first 3 will be processed.", + "Array of integer test IDs to fetch RCA data for (maximum 3 IDs). These must be numeric test IDs, not session IDs or strings. If not provided, use the listTestIds tool to get all failed testcases. If more than 3 IDs are provided, only the first 3 will be processed.", ), }; diff --git a/src/tools/rca-agent-utils/rca-data.ts b/src/tools/rca-agent-utils/rca-data.ts index 1e66220..de7949f 100644 --- a/src/tools/rca-agent-utils/rca-data.ts +++ b/src/tools/rca-agent-utils/rca-data.ts @@ -97,11 +97,11 @@ async function updateProgress( } async function fetchInitialRCA( - testId: string, + testId: number, headers: Record, baseUrl: string, ): Promise { - const url = baseUrl.replace("{testId}", testId); + const url = baseUrl.replace("{testId}", testId.toString()); try { const response = await fetch(url, { headers }); @@ -179,7 +179,7 @@ async function pollRCAResults( await Promise.allSettled( inProgressCases.map(async (tc) => { try { - const pollUrl = baseUrl.replace("{testId}", tc.id); + const pollUrl = baseUrl.replace("{testId}", tc.id.toString()); const response = await fetch(pollUrl, { headers }); if (!response.ok) { const errorText = await response.text(); @@ -240,7 +240,7 @@ async function pollRCAResults( } export async function getRCAData( - testIds: string[], + testIds: number[], authString: string, context?: ScanProgressContext, ): Promise { diff --git a/src/tools/rca-agent-utils/types.ts b/src/tools/rca-agent-utils/types.ts index b2795dd..41294d2 100644 --- a/src/tools/rca-agent-utils/types.ts +++ b/src/tools/rca-agent-utils/types.ts @@ -21,7 +21,7 @@ export interface TestRun { } export interface FailedTestInfo { - test_id: string; + test_id: number; test_name: string; } @@ -39,8 +39,8 @@ export enum RCAState { } export interface RCATestCase { - id: string; - testRunId: string; + id: number; + testRunId: number; state: RCAState; rcaData?: any; } diff --git a/src/tools/rca-agent.ts b/src/tools/rca-agent.ts index 4b341e4..920828f 100644 --- a/src/tools/rca-agent.ts +++ b/src/tools/rca-agent.ts @@ -60,7 +60,7 @@ export async function getBuildIdTool( // Tool function that fetches RCA data export async function fetchRCADataTool( - args: { testId: string[] }, + args: { testId: number[] }, config: BrowserStackConfig, ): Promise { try {