Skip to content

Conversation

@ManojTestsigma
Copy link
Contributor

@ManojTestsigma ManojTestsigma commented Aug 4, 2025

Jira

https://testsigma.atlassian.net/browse/TE-28689

Addon Name: Store Network Logs Data
Addon account: https://jarvis.testsigma.com/ui/tenants/2817/addons

fix

updated the devtools to chrome version 137
added nlp to retrieve payload data
added nlp to get the response time of endpoint

Summary by CodeRabbit

  • New Features

    • Added actions to retrieve HTTP status code, response time, and payload data for tracked URLs, storing results in runtime variables.
    • Introduced functionality to extract specific header values from network requests.
  • Improvements

    • Enhanced network tracking to capture and aggregate status codes, response times, payloads, request headers, and response bodies.
    • Improved error handling and logging for unsupported drivers and network interception failures.
  • Upgrades

    • Updated Selenium and DevTools dependencies to newer versions for improved compatibility and features.
  • Refactor

    • Simplified logic by focusing on header extraction and consolidating network data storage.

@coderabbitai
Copy link

coderabbitai bot commented Aug 4, 2025

Walkthrough

This update introduces three new web action classes for extracting network data (payload, response time, status code), significantly refactors the request/response tracking logic to use updated Selenium DevTools and consolidated data storage, and overhauls utility methods to support granular retrieval of headers, payloads, status codes, and response times. The project dependencies are also upgraded.

Changes

Cohort / File(s) Change Summary
Dependency and DevTools Upgrade
store_network_logs_data/pom.xml
Bumped project version, upgraded Selenium Java and DevTools dependencies, and updated DevTools protocol artifact.
Request Header Extraction Refactor
store_network_logs_data/src/main/java/com/testsigma/addons/web/GetDataFromRequestBody.java
Refactored to extract specific header values instead of parsing request body JSON; removed recursive JSON logic and updated error handling.
New Web Actions for Network Data
store_network_logs_data/src/main/java/com/testsigma/addons/web/GetPayloadDataForGivenUrl.java, store_network_logs_data/src/main/java/com/testsigma/addons/web/GetResponseTime.java, store_network_logs_data/src/main/java/com/testsigma/addons/web/GetStatusCode.java
Added new classes to retrieve payload data, response time, and status code for tracked URLs, each storing results in runtime variables.
Network Tracking Logic Overhaul
store_network_logs_data/src/main/java/com/testsigma/addons/web/StartTracking.java
Updated to use newer DevTools version, improved driver compatibility checks, consolidated all network data capture and storage, enhanced logging and error handling.
Utility Methods Expansion and Refactor
store_network_logs_data/src/main/java/com/testsigma/addons/web/utilities/ResponseDataUtilities.java
Refactored to support granular storage and retrieval of request headers, status codes, payloads, and response times; removed old request body methods, added header extraction, and improved error handling.

Sequence Diagram(s)

sequenceDiagram
    participant TestStep as Test Step
    participant WebAction as WebAction (e.g., GetStatusCode)
    participant Utilities as ResponseDataUtilities
    participant Storage as Data Storage

    TestStep->>WebAction: execute()
    WebAction->>Utilities: getStatusCodeData(runId, logger)
    Utilities->>Storage: Retrieve stored network data for runId
    Utilities-->>WebAction: Return status code
    WebAction->>TestStep: Store status code in runtime variable
Loading
sequenceDiagram
    participant TestStep as Test Step
    participant StartTracking as StartTracking Action
    participant DevTools as Selenium DevTools
    participant Utilities as ResponseDataUtilities
    participant Storage as Data Storage

    TestStep->>StartTracking: execute()
    StartTracking->>DevTools: Start session, listen for requests/responses
    DevTools-->>StartTracking: On request/response events
    StartTracking->>Utilities: saveAllNetworkData(runId, allData, logger)
    Utilities->>Storage: Store all network data as JSON
    StartTracking->>TestStep: Return success/failure
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • Ganesh-Testsigma
  • vigneshtestsigma

Poem

In the warren where the network logs hop,
New actions now nibble at headers on top.
Status and payload, response time in tow,
With DevTools upgraded, the data will flow!
A carrot for progress, a hop for each test—
This rabbit approves: your code is the best! 🥕✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch PRE-398

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🔭 Outside diff range comments (1)
store_network_logs_data/src/main/java/com/testsigma/addons/web/utilities/ResponseDataUtilities.java (1)

12-269: Potential thread safety issues with concurrent test execution

The utility class uses static methods that read/write to files without synchronization. If multiple tests run concurrently with the same runId, this could lead to race conditions and data corruption.

Consider adding synchronization or using thread-safe alternatives:

private static final Object fileLock = new Object();

private static void saveAllData(Long runId, JsonObject jsonObject, Logger logger) throws Exception {
    synchronized (fileLock) {
        // existing implementation
    }
}

Or use a thread-safe data structure like ConcurrentHashMap to store data in memory instead of files.

🧹 Nitpick comments (9)
store_network_logs_data/src/main/java/com/testsigma/addons/web/GetDataFromRequestBody.java (2)

18-22: Consider renaming class to reflect actual functionality.

The class name GetDataFromRequestBody is misleading since it now retrieves header values, not request body data. Consider renaming to GetDataFromRequestHeader or similar to accurately reflect its purpose.


53-55: Improve exception handling specificity.

The catch block for IllegalStateException provides a helpful contextual error message, but consider whether other specific exceptions from getSpecificHeaderValue should be handled differently.

store_network_logs_data/src/main/java/com/testsigma/addons/web/GetResponseTime.java (2)

32-36: Add user feedback messages for better UX.

Consider adding success and error messages using setSuccessMessage() and setErrorMessage() methods for better user feedback, similar to other action classes in the codebase.

 int responseTime = ResponseDataUtilities.getResponseTime(testCaseResult.getId(), logger);
 // store the response time in the runtime variable
 runTimeData.setKey(runtimeVariable.getValue().toString());
 runTimeData.setValue(responseTime);
+setSuccessMessage("Response time retrieved successfully: " + responseTime + "ms");
 return Result.SUCCESS;

38-41: Improve error handling and logging level.

Consider using logger.warn() or logger.error() instead of logger.debug() for better error visibility, and add setErrorMessage() for user feedback.

 } catch (Exception e) {
-    logger.debug("Error in getting response time: " + e.getMessage());
+    logger.warn("Error in getting response time: " + e.getMessage());
+    setErrorMessage("Failed to retrieve response time: " + e.getMessage());
     return Result.FAILED;
 }
store_network_logs_data/src/main/java/com/testsigma/addons/web/GetStatusCode.java (1)

31-31: Remove unnecessary variable initialization.

The Result result = Result.SUCCESS; initialization is unnecessary since you return Result.SUCCESS directly later. Consider removing this line for cleaner code.

-Result result = Result.SUCCESS;
 int statusCodeFromFile = getStatusCodeData(testCaseResult.getId(), logger);
store_network_logs_data/src/main/java/com/testsigma/addons/web/GetPayloadDataForGivenUrl.java (1)

20-21: Consider adding custom screenshot configuration.

The action is configured with useCustomScreenshot = false. Verify if this setting is appropriate for payload data retrieval scenarios, as screenshots might be helpful for debugging network-related issues.

store_network_logs_data/src/main/java/com/testsigma/addons/web/StartTracking.java (1)

173-177: Response time calculation could be affected by system clock changes

The response time calculation uses System.currentTimeMillis() which is affected by system clock changes. While rare, this could result in negative or incorrect response times.

Consider using System.nanoTime() for more accurate elapsed time measurement:

-final long[] requestStartTimes = new long[1];
+final long[] requestStartNanos = new long[1];

 // In request listener:
-requestStartTimes[0] = System.currentTimeMillis();
+requestStartNanos[0] = System.nanoTime();

 // In response listener:
-long responseTime = 0;
-if (requestStartTimes[0] > 0) {
-    responseTime = System.currentTimeMillis() - requestStartTimes[0];
-    logger.info("Response time: " + responseTime + "ms");
-}
+long responseTimeMs = 0;
+if (requestStartNanos[0] > 0) {
+    responseTimeMs = (System.nanoTime() - requestStartNanos[0]) / 1_000_000;
+    logger.info("Response time: " + responseTimeMs + "ms");
+}
store_network_logs_data/src/main/java/com/testsigma/addons/web/utilities/ResponseDataUtilities.java (2)

23-23: Fix grammatical error in log message

-logger.info("Did not saved data for the current testcase " + e.getMessage());
+logger.info("Did not save data for the current testcase " + e.getMessage());

106-178: Multiple overlapping methods for saving network data

There are several methods that save partial network data (addStatusCodeAndRequestHeadersData, addAllNetworkData, addStatusCodeData, addRequestHeadersData) which could lead to data inconsistency if used incorrectly. Since StartTracking uses saveAllNetworkData to save all data atomically, consider whether these partial save methods are still needed.

Consider either:

  1. Removing unused partial save methods to simplify the API
  2. Adding clear documentation about when to use each method
  3. Making partial save methods private if they're only for internal use
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 045a344 and a6b8b37.

📒 Files selected for processing (7)
  • store_network_logs_data/pom.xml (3 hunks)
  • store_network_logs_data/src/main/java/com/testsigma/addons/web/GetDataFromRequestBody.java (2 hunks)
  • store_network_logs_data/src/main/java/com/testsigma/addons/web/GetPayloadDataForGivenUrl.java (1 hunks)
  • store_network_logs_data/src/main/java/com/testsigma/addons/web/GetResponseTime.java (1 hunks)
  • store_network_logs_data/src/main/java/com/testsigma/addons/web/GetStatusCode.java (1 hunks)
  • store_network_logs_data/src/main/java/com/testsigma/addons/web/StartTracking.java (3 hunks)
  • store_network_logs_data/src/main/java/com/testsigma/addons/web/utilities/ResponseDataUtilities.java (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
store_network_logs_data/src/main/java/com/testsigma/addons/web/GetDataFromRequestBody.java (1)
store_network_logs_data/src/main/java/com/testsigma/addons/web/utilities/ResponseDataUtilities.java (1)
  • ResponseDataUtilities (12-269)
store_network_logs_data/src/main/java/com/testsigma/addons/web/utilities/ResponseDataUtilities.java (1)
store_network_logs_data/src/main/java/com/testsigma/addons/web/utilities/FileUtilities.java (1)
  • FileUtilities (10-71)
store_network_logs_data/src/main/java/com/testsigma/addons/web/StartTracking.java (7)
store_network_logs_data/src/main/java/com/testsigma/addons/web/utilities/ResponseDataUtilities.java (1)
  • ResponseDataUtilities (12-269)
store_network_logs_data/src/main/java/com/testsigma/addons/web/GetPayloadDataForGivenUrl.java (1)
  • Data (17-62)
store_network_logs_data/src/main/java/com/testsigma/addons/web/GetResponseTime.java (1)
  • Data (14-44)
store_network_logs_data/src/main/java/com/testsigma/addons/web/GetDataFromRequestBody.java (1)
  • Data (17-76)
store_network_logs_data/src/main/java/com/testsigma/addons/web/GetStatusCode.java (1)
  • Data (14-49)
store_network_logs_data/src/main/java/com/testsigma/addons/web/GetDataFromResponseBody.java (1)
  • Data (22-146)
store_network_logs_data/src/main/java/com/testsigma/addons/web/NetworkTrafficCaptureActionLocal.java (1)
  • Data (26-211)
🔇 Additional comments (6)
store_network_logs_data/pom.xml (2)

9-9: LGTM! Version increment is appropriate.

The project version bump from 1.0.2 to 1.0.5 properly reflects the significant functionality enhancements in this release.


51-51: Confirmed Selenium 4.33.0 compatibility with Chrome 137

Selenium Java 4.33.0 and org.seleniumhq.selenium:selenium-devtools-v137:4.33.0 officially support Chrome v137, so the current dependency bump satisfies the PR objective.

• File: store_network_logs_data/pom.xml
– Lines 51, 71–72

Optionally, you may upgrade to Selenium 4.34.0 (latest stable as of August 2025) for the newest fixes, but no compatibility changes are required.

store_network_logs_data/src/main/java/com/testsigma/addons/web/GetDataFromRequestBody.java (1)

48-65: LGTM! Simplified header retrieval implementation.

The refactored implementation using ResponseDataUtilities.getSpecificHeaderValue is much cleaner and more maintainable than the previous recursive JSON parsing approach. The error handling and logging are appropriate.

store_network_logs_data/src/main/java/com/testsigma/addons/web/GetStatusCode.java (1)

32-42: LGTM! Well-implemented status code retrieval.

The implementation properly handles the case where status code is not found (-1), provides good logging and user feedback messages, and follows the established pattern for action classes.

store_network_logs_data/src/main/java/com/testsigma/addons/web/GetPayloadDataForGivenUrl.java (1)

36-59: LGTM! Well-structured payload data retrieval.

The implementation properly retrieves payload data using the utility method, converts it to string format, and provides comprehensive logging and user feedback. The error handling follows the established pattern.

store_network_logs_data/src/main/java/com/testsigma/addons/web/utilities/ResponseDataUtilities.java (1)

156-159: Header parsing may fail for values containing colons

The current parsing logic uses indexOf(": ") which would incorrectly parse headers with colons in their values (e.g., "Location: http://example.com:8080").

Use indexOf() with a limit to only split on the first colon:

-int colonIndex = headerLine.indexOf(": ");
-if (colonIndex > 0) {
-    String key = headerLine.substring(0, colonIndex).trim();
-    String value = headerLine.substring(colonIndex + 2).trim();
+int colonIndex = headerLine.indexOf(":");
+if (colonIndex > 0 && colonIndex < headerLine.length() - 1) {
+    String key = headerLine.substring(0, colonIndex).trim();
+    String value = headerLine.substring(colonIndex + 1).trim();

Likely an incorrect or invalid review comment.


public class GetPayloadDataForGivenUrl extends WebAction {

@TestData(reference = "runtim_variable", isRuntimeVariable = true)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix typo in TestData reference.

There's a typo in the @TestData annotation: "runtim_variable" should be "runtime_variable". This will cause runtime binding issues.

-@TestData(reference = "runtim_variable", isRuntimeVariable = true)
+@TestData(reference = "runtime_variable", isRuntimeVariable = true)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@TestData(reference = "runtim_variable", isRuntimeVariable = true)
@TestData(reference = "runtime_variable", isRuntimeVariable = true)
🤖 Prompt for AI Agents
In
store_network_logs_data/src/main/java/com/testsigma/addons/web/GetPayloadDataForGivenUrl.java
at line 26, correct the typo in the @TestData annotation by changing the
reference value from "runtim_variable" to "runtime_variable" to ensure proper
runtime binding.

logger.info("Status code retrieved: " + statusCodeFromFile);
// Store the status code in the runtime variable
runTimeData.setKey(statusCodeVariable.getValue().toString());
runTimeData.setValue(String.valueOf(statusCodeFromFile));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify type consistency across similar actions.

The status code is converted to String before storing in runtime variable. Ensure this type handling is consistent with other similar actions like GetResponseTime which stores an int directly.


🏁 Script executed:

#!/bin/bash
# Check how other action classes handle numeric values in runtime variables
rg -A 3 -B 1 "runTimeData\.setValue" --type java

Length of output: 165833


🏁 Script executed:

#!/bin/bash
# Display the declaration and usage of responseTime in GetResponseTime.java
rg -n "responseTime" -C 3 store_network_logs_data/src/main/java/com/testsigma/addons/web/GetResponseTime.java

Length of output: 683


Align numeric runtime data storage in GetStatusCode

To keep numeric values consistent with GetResponseTime—which passes the int directly to runTimeData.setValue—update GetStatusCode to avoid converting the status code to a String.

Locations to update:

  • store_network_logs_data/src/main/java/com/testsigma/addons/web/GetStatusCode.java, line 40

Suggested diff:

-           runTimeData.setValue(String.valueOf(statusCodeFromFile));
+           runTimeData.setValue(statusCodeFromFile);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
runTimeData.setValue(String.valueOf(statusCodeFromFile));
runTimeData.setValue(statusCodeFromFile);
🤖 Prompt for AI Agents
In
store_network_logs_data/src/main/java/com/testsigma/addons/web/GetStatusCode.java
at line 40, the status code is being converted to a String before passing to
runTimeData.setValue. To align with GetResponseTime and maintain numeric
consistency, pass the statusCodeFromFile integer directly to
runTimeData.setValue without converting it to a String.

Comment on lines +59 to +71
logger.warn("DevTools not supported by this driver. Using alternative network logging approach.");
// For drivers that don't support DevTools, we'll use browser logs
try {
// Enable browser logging
logger.info("Enabling browser performance logging...");
// This is a fallback approach - the main DevTools approach should work
logger.info("DevTools approach failed, but action completed successfully.");
return Result.SUCCESS;
} catch (Exception e) {
logger.warn("Fallback approach also failed: " + e.getMessage());
return Result.SUCCESS;
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Misleading fallback logic that returns SUCCESS without implementing tracking

When DevTools is not supported, the code logs that it will use an "alternative network logging approach" but doesn't actually implement any alternative tracking. It then returns Result.SUCCESS, which could mislead users into thinking tracking is working when it's not.

Either implement actual fallback tracking or return Result.FAILED with a clear error message:

 } else {
-    logger.warn("DevTools not supported by this driver. Using alternative network logging approach.");
-    // For drivers that don't support DevTools, we'll use browser logs
-    try {
-        // Enable browser logging
-        logger.info("Enabling browser performance logging...");
-        // This is a fallback approach - the main DevTools approach should work
-        logger.info("DevTools approach failed, but action completed successfully.");
-        return Result.SUCCESS;
-    } catch (Exception e) {
-        logger.warn("Fallback approach also failed: " + e.getMessage());
-        return Result.SUCCESS;
-    }
+    logger.error("DevTools not supported by this driver.");
+    setErrorMessage("DevTools is required for network tracking but not supported by this driver");
+    return Result.FAILED;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
logger.warn("DevTools not supported by this driver. Using alternative network logging approach.");
// For drivers that don't support DevTools, we'll use browser logs
try {
// Enable browser logging
logger.info("Enabling browser performance logging...");
// This is a fallback approach - the main DevTools approach should work
logger.info("DevTools approach failed, but action completed successfully.");
return Result.SUCCESS;
} catch (Exception e) {
logger.warn("Fallback approach also failed: " + e.getMessage());
return Result.SUCCESS;
}
}
} else {
logger.error("DevTools not supported by this driver.");
setErrorMessage("DevTools is required for network tracking but not supported by this driver");
return Result.FAILED;
}
🤖 Prompt for AI Agents
In
store_network_logs_data/src/main/java/com/testsigma/addons/web/StartTracking.java
between lines 59 and 71, the fallback logic for unsupported DevTools logs a
message about using an alternative network logging approach but does not
implement any actual tracking and returns Result.SUCCESS, which is misleading.
To fix this, either implement the alternative tracking logic properly or change
the return value to Result.FAILED and log a clear error message indicating that
tracking could not be started due to lack of DevTools support and no fallback
implementation.

Comment on lines +95 to +96
if (requestUrl.contains(urlVariable.getValue().toString()) &&
requestMethod.equalsIgnoreCase(methodValue.getValue().toString())) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

URL matching may capture unintended requests

Using contains() for URL matching could capture unintended requests. For example, if urlVariable is "api", it would match both "api.example.com" and "example.com/api".

Consider using more precise matching or allowing regex patterns:

-if (requestUrl.contains(urlVariable.getValue().toString()) &&
-        requestMethod.equalsIgnoreCase(methodValue.getValue().toString())) {
+String urlPattern = urlVariable.getValue().toString();
+if ((requestUrl.equals(urlPattern) || requestUrl.matches(urlPattern)) &&
+        requestMethod.equalsIgnoreCase(methodValue.getValue().toString())) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (requestUrl.contains(urlVariable.getValue().toString()) &&
requestMethod.equalsIgnoreCase(methodValue.getValue().toString())) {
String urlPattern = urlVariable.getValue().toString();
if ((requestUrl.equals(urlPattern) || requestUrl.matches(urlPattern)) &&
requestMethod.equalsIgnoreCase(methodValue.getValue().toString())) {
🤖 Prompt for AI Agents
In
store_network_logs_data/src/main/java/com/testsigma/addons/web/StartTracking.java
around lines 95 to 96, the use of contains() for URL matching is too broad and
may match unintended URLs. Replace contains() with a more precise matching
approach such as equals(), startsWith(), or implement regex pattern matching to
ensure only the intended URLs are matched. Adjust the logic to handle regex
patterns if you choose that route, validating the urlVariable value accordingly.

Comment on lines +242 to +257
public static int getResponseTime(Long runId, Logger logger) throws Exception {
logger.info("Getting response time for runId: " + runId);
String encodedData = FileUtilities.readFromFile(runId);
if (encodedData == null || encodedData.isEmpty()) {
logger.info("Response time data is not present for runId: " + runId);
throw new Exception("Failed to get any response time for runId: " + runId);

}

String json = new String(Base64.getDecoder().decode(encodedData));
try {
JsonObject data = gson.fromJson(json, JsonObject.class);
if (data != null && data.has("responseTime")) {
int responseTime = data.get("responseTime").getAsInt();
logger.info("Got response time for runId: " + runId + ", responseTime: " + responseTime);
return responseTime;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Response time data type mismatch could cause overflow

The method returns int but response times are stored as long in StartTracking. This could cause overflow for requests taking longer than ~24 days (Integer.MAX_VALUE milliseconds).

Change the return type to match the stored data type:

-public static int getResponseTime(Long runId, Logger logger) throws Exception {
+public static long getResponseTime(Long runId, Logger logger) throws Exception {
     // ...
     if (data != null && data.has("responseTime")) {
-        int responseTime = data.get("responseTime").getAsInt();
+        long responseTime = data.get("responseTime").getAsLong();
         logger.info("Got response time for runId: " + runId + ", responseTime: " + responseTime);
         return responseTime;
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public static int getResponseTime(Long runId, Logger logger) throws Exception {
logger.info("Getting response time for runId: " + runId);
String encodedData = FileUtilities.readFromFile(runId);
if (encodedData == null || encodedData.isEmpty()) {
logger.info("Response time data is not present for runId: " + runId);
throw new Exception("Failed to get any response time for runId: " + runId);
}
String json = new String(Base64.getDecoder().decode(encodedData));
try {
JsonObject data = gson.fromJson(json, JsonObject.class);
if (data != null && data.has("responseTime")) {
int responseTime = data.get("responseTime").getAsInt();
logger.info("Got response time for runId: " + runId + ", responseTime: " + responseTime);
return responseTime;
public static long getResponseTime(Long runId, Logger logger) throws Exception {
logger.info("Getting response time for runId: " + runId);
String encodedData = FileUtilities.readFromFile(runId);
if (encodedData == null || encodedData.isEmpty()) {
logger.info("Response time data is not present for runId: " + runId);
throw new Exception("Failed to get any response time for runId: " + runId);
}
String json = new String(Base64.getDecoder().decode(encodedData));
try {
JsonObject data = gson.fromJson(json, JsonObject.class);
if (data != null && data.has("responseTime")) {
- int responseTime = data.get("responseTime").getAsInt();
+ long responseTime = data.get("responseTime").getAsLong();
logger.info("Got response time for runId: " + runId + ", responseTime: " + responseTime);
return responseTime;
🤖 Prompt for AI Agents
In
store_network_logs_data/src/main/java/com/testsigma/addons/web/utilities/ResponseDataUtilities.java
around lines 242 to 257, the getResponseTime method returns an int but the
response time is stored as a long, risking overflow for large values. Change the
method's return type from int to long and update the variable holding the
response time to long accordingly to match the stored data type and prevent
overflow.

@ManojTestsigma ManojTestsigma merged commit f20d8b6 into dev Aug 5, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants