[CUS-12422] Added folder and file actions to windows advanced type.#385
[CUS-12422] Added folder and file actions to windows advanced type.#385ManojTestsigma wants to merge 1 commit intodevfrom
Conversation
📝 WalkthroughWalkthroughA new Maven JAR project Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Actionable comments posted: 9
🧹 Nitpick comments (3)
folder_and_file_actions_11365282608597864633118400917122709149/pom.xml (1)
69-81: Harden shade configuration to reduce runtime classpath collisions.At Lines 69-81, the shade setup is very broad. For an addon carrying Selenium/Appium stacks, consider explicit artifact filtering/relocation strategy to avoid dependency clashes in the host runtime.
Suggested baseline hardening
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.2.4</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> + <configuration> + <createDependencyReducedPom>true</createDependencyReducedPom> + <minimizeJar>true</minimizeJar> + </configuration> </execution> </executions> </plugin>Use this only if your addon runtime doesn’t depend on reflective access to trimmed classes; otherwise keep
minimizeJaroff and rely on explicit includes/excludes.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@folder_and_file_actions_11365282608597864633118400917122709149/pom.xml` around lines 69 - 81, The maven-shade-plugin configuration is too broad and can cause runtime classpath collisions; update the plugin block for artifactId maven-shade-plugin (version 3.2.4) to add a conservative shading strategy: enable explicit relocations for known conflicting packages (e.g., selenium/appium group packages), add filters/includes/excludes to limit which dependencies are packaged, and consider setting minimizeJar only if you don't rely on reflective/trimmed classes; modify the <executions> -> <execution> for the shade goal to include <relocations> and <filters> entries and adjust minimizeJar accordingly to harden the shaded artifact.folder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/windowsAdvanced/VerifyFileWithNamePresenceWithFileSize.java (1)
33-67: Consider extracting shared file-size verification logic.This method duplicates near-identical logic present in multiple actions, and the same messaging bug appeared in more than one class. A shared helper would reduce drift risk.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@folder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/windowsAdvanced/VerifyFileWithNamePresenceWithFileSize.java` around lines 33 - 67, The execute() method in VerifyFileWithNamePresenceWithFileSize duplicates file-size verification and message construction logic found in other actions; extract that repeated logic into a shared helper (e.g., a new method in FolderUtilities or a utility class) that accepts parameters (File file, long expectedSizeKB, String fileName, String folderPath, Logger logger) and returns a result object or boolean plus canonical success/error messages; update VerifyFileWithNamePresenceWithFileSize.execute() to call this helper (replace the inline size calculation, comparison using file.length()/1000 and message formatting, and branching on pass/fail) and reuse the same helper from other classes to centralize the comparison and fix the messaging bug.folder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/windowsAdvanced/VerifyFileContainingNamePresenceWithFileSize.java (1)
3-3: Avoid cross-platform package coupling forFolderUtilities.
windowsAdvancedcode importingcom.testsigma.addons.web.folderutil.FolderUtilitiesmakes module boundaries harder to maintain. Consider moving shared file/folder helpers to a neutral package (for example,com.testsigma.addons.common.folderutil).🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@folder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/windowsAdvanced/VerifyFileContainingNamePresenceWithFileSize.java` at line 3, The VerifyFileContainingNamePresenceWithFileSize class currently imports FolderUtilities from com.testsigma.addons.web.folderutil which couples a Windows-specific addon to a web package; refactor by moving the FolderUtilities helper to a neutral package (e.g., com.testsigma.addons.common.folderutil), update the import in VerifyFileContainingNamePresenceWithFileSize to import com.testsigma.addons.common.folderutil.FolderUtilities, and update any references, package declarations and module/resource entries affected (including the FolderUtilities class file location and its package statement) so all callers use the new neutral package.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@folder_and_file_actions_11365282608597864633118400917122709149/pom.xml`:
- Around line 42-46: The TestNG dependency org.testng:testng is currently left
at default (compile) scope and will be packaged into the shaded addon JAR;
change the dependency declaration for groupId org.testng and artifactId testng
(version 6.14.3) to use test scope by adding a <scope>test</scope> element so
the test framework is excluded from the runtime artifact.
- Line 17: The pom declares outdated or milestone dependency versions (property
junit.jupiter.version and dependencies junit-jupiter-api, testng, selenium-java,
java-client, jackson-annotations); update junit.jupiter.version and the specific
dependency entries (junit-jupiter-api, testng, selenium-java, java-client,
jackson-annotations) to current stable releases (e.g., junit 6.0.3, testng
7.12.0, selenium 4.43.0, java-client 10.1.1, jackson-annotations 2.18.6) or your
approved versions, run a full build/test cycle to ensure compatibility, and
cross-check the updated versions against known security advisories before
publishing.
In
`@folder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/web/IfVerifyFileWithNamePresenceWithFileSize.java`:
- Around line 59-62: In the null-file branch inside class
IfVerifyFileWithNamePresenceWithFileSize where you currently set result =
Result.FAILED and call setErrorMessage(String.format(util.FOLDER_NOT_FOUND,
folderPath)), replace the misleading util.FOLDER_NOT_FOUND usage with the
correct file-not-found constant (util.FILE_NOT_FOUND) and format the message
with the missing file identifier (e.g., fileName or the full file path) so
setErrorMessage reports the missing file; keep the Result.FAILED and
setErrorMessage call but swap the constant and argument to reference the file
rather than the folder.
- Line 41: The parse of size_ in IfVerifyFileWithNamePresenceWithFileSize can
throw NumberFormatException or accept negative values; wrap the
Long.parseLong(size_.getValue().toString()) call in a try/catch that catches
NumberFormatException, log/set a clear error message and return a FAILED result
from the action, and after parsing explicitly check if size < 0 and likewise set
an error and return FAILED; update the method that contains the parse (the
execution flow around the size_ variable) to use the validated long value only
after these checks.
In
`@folder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/windowsAdvanced/IfVerifyFileWithNamePresenceWithFileSize.java`:
- Around line 59-62: The code in IfVerifyFileWithNamePresenceWithFileSize
incorrectly sets the error message to util.FOLDER_NOT_FOUND after confirming the
folder exists; change the error path where result is set to Result.FAILED to use
the file-missing template instead by replacing util.FOLDER_NOT_FOUND with
util.FILE_NOT_FOUND in the setErrorMessage call (keep setting result =
Result.FAILED and leave surrounding logic unchanged).
- Line 41: The direct call to Long.parseLong(size_.getValue().toString()) in
IfVerifyFileWithNamePresenceWithFileSize can throw NumberFormatException or
accept negative values; wrap the parse in a try/catch and validate the parsed
value: catch NumberFormatException and return Result.FAILED with a clear
validation message (e.g., "Invalid file size: must be a non-negative integer"),
and if the parsed long is negative also return Result.FAILED with a message
rejecting negative KB; keep references to the existing variable size_ and the
parse call (Long.parseLong) so the change is localized to that
parsing/validation block inside the class's action method.
In
`@folder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/windowsAdvanced/VerifyFileContainingNamePresenceWithFileSize.java`:
- Around line 56-57: Update the user-facing error string in
VerifyFileContainingNamePresenceWithFileSize where setErrorMessage(...) is
called: replace the grammatically incorrect message ("The files exists with
containing name ...") with a clear sentence that references fileName,
folderPath, fileSize and size variables (for example: "A file containing '%s'
exists in folder '%s' but its size %s KB is not greater than %s KB"); ensure you
only change the message text in the setErrorMessage(String.format(...)) call so
the format specifiers and variables (fileName, folderPath, fileSize, size)
remain correct.
In
`@folder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/windowsAdvanced/VerifyFileWithNamePresenceWithFileSize.java`:
- Around line 57-60: In the file-not-found branch inside
VerifyFileWithNamePresenceWithFileSize, replace the incorrect
util.FOLDER_NOT_FOUND error message with the file-missing constant
util.NO_FILE_EXISTS_ERROR_MSG (and include the target file identifier, e.g.,
fileName or expected file path variable) so setErrorMessage(...) reports the
missing file rather than a missing folder; update the setErrorMessage call in
that else branch to use util.NO_FILE_EXISTS_ERROR_MSG and format it with the
file identifier.
- Line 39: The code directly calls Long.parseLong on size_.getValue() and
assumes it's a valid non-negative number; wrap the parse in a try/catch to catch
NumberFormatException and also validate that the parsed long (the variable size)
is >= 0, and if either check fails set the step/result to FAILED with a clear
message (e.g., "Invalid test-data size: '<value>'" or "Negative size not
allowed: <value>") and return early; update the logic in class
VerifyFileWithNamePresenceWithFileSize around the
Long.parseLong(size_.getValue().toString()) usage so invalid or negative inputs
produce a controlled FAILED result instead of throwing.
---
Nitpick comments:
In `@folder_and_file_actions_11365282608597864633118400917122709149/pom.xml`:
- Around line 69-81: The maven-shade-plugin configuration is too broad and can
cause runtime classpath collisions; update the plugin block for artifactId
maven-shade-plugin (version 3.2.4) to add a conservative shading strategy:
enable explicit relocations for known conflicting packages (e.g.,
selenium/appium group packages), add filters/includes/excludes to limit which
dependencies are packaged, and consider setting minimizeJar only if you don't
rely on reflective/trimmed classes; modify the <executions> -> <execution> for
the shade goal to include <relocations> and <filters> entries and adjust
minimizeJar accordingly to harden the shaded artifact.
In
`@folder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/windowsAdvanced/VerifyFileContainingNamePresenceWithFileSize.java`:
- Line 3: The VerifyFileContainingNamePresenceWithFileSize class currently
imports FolderUtilities from com.testsigma.addons.web.folderutil which couples a
Windows-specific addon to a web package; refactor by moving the FolderUtilities
helper to a neutral package (e.g., com.testsigma.addons.common.folderutil),
update the import in VerifyFileContainingNamePresenceWithFileSize to import
com.testsigma.addons.common.folderutil.FolderUtilities, and update any
references, package declarations and module/resource entries affected (including
the FolderUtilities class file location and its package statement) so all
callers use the new neutral package.
In
`@folder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/windowsAdvanced/VerifyFileWithNamePresenceWithFileSize.java`:
- Around line 33-67: The execute() method in
VerifyFileWithNamePresenceWithFileSize duplicates file-size verification and
message construction logic found in other actions; extract that repeated logic
into a shared helper (e.g., a new method in FolderUtilities or a utility class)
that accepts parameters (File file, long expectedSizeKB, String fileName, String
folderPath, Logger logger) and returns a result object or boolean plus canonical
success/error messages; update VerifyFileWithNamePresenceWithFileSize.execute()
to call this helper (replace the inline size calculation, comparison using
file.length()/1000 and message formatting, and branching on pass/fail) and reuse
the same helper from other classes to centralize the comparison and fix the
messaging bug.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9102f54d-8c5d-4c87-98c6-9deb72926409
📒 Files selected for processing (13)
folder_and_file_actions_11365282608597864633118400917122709149/pom.xmlfolder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/web/IfVerifyFileContainingNamePresence.javafolder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/web/IfVerifyFileContainingNamePresenceWithFileSize.javafolder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/web/IfVerifyFileWithNamePresence.javafolder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/web/IfVerifyFileWithNamePresenceWithFileSize.javafolder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/windowsAdvanced/IfVerifyFileContainingNamePresence.javafolder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/windowsAdvanced/IfVerifyFileContainingNamePresenceWithFileSize.javafolder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/windowsAdvanced/IfVerifyFileWithNamePresence.javafolder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/windowsAdvanced/IfVerifyFileWithNamePresenceWithFileSize.javafolder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/windowsAdvanced/VerifyFileContainingNamePresence.javafolder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/windowsAdvanced/VerifyFileContainingNamePresenceWithFileSize.javafolder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/windowsAdvanced/VerifyFileWithNamePresence.javafolder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/windowsAdvanced/VerifyFileWithNamePresenceWithFileSize.java
| <maven.compiler.source>11</maven.compiler.source> | ||
| <maven.compiler.target>11</maven.compiler.target> | ||
| <testsigma.sdk.version>1.2.24_cloud</testsigma.sdk.version> | ||
| <junit.jupiter.version>5.8.0-M1</junit.jupiter.version> |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Checking latest versions on Maven Central..."
for ga in \
"org.junit.jupiter:junit-jupiter-api" \
"org.testng:testng" \
"org.seleniumhq.selenium:selenium-java" \
"io.appium:java-client" \
"com.fasterxml.jackson.core:jackson-annotations" \
"org.apache.maven.plugins:maven-shade-plugin"
do
g="${ga%%:*}"
a="${ga##*:}"
q="https://search.maven.org/solrsearch/select?q=g:%22${g}%22+AND+a:%22${a}%22&rows=1&wt=json"
latest=$(curl -s "$q" | jq -r '.response.docs[0].latestVersion // "N/A"')
echo "${ga} -> latest: ${latest}"
done
echo
echo "Checking OSV advisories for currently pinned coordinates..."
python - <<'PY'
import json, urllib.request
deps = [
("org.junit.jupiter", "junit-jupiter-api", "5.8.0-M1"),
("org.testng", "testng", "6.14.3"),
("org.seleniumhq.selenium", "selenium-java", "4.14.1"),
("io.appium", "java-client", "9.0.0"),
("com.fasterxml.jackson.core", "jackson-annotations", "2.13.0"),
]
url = "https://api.osv.dev/v1/query"
for g,a,v in deps:
body = {
"package": {"ecosystem":"Maven","name":f"{g}:{a}"},
"version": v
}
req = urllib.request.Request(url, data=json.dumps(body).encode(), headers={"Content-Type":"application/json"})
with urllib.request.urlopen(req) as r:
data = json.loads(r.read().decode())
vulns = data.get("vulns", [])
print(f"{g}:{a}:{v} -> vulnerabilities: {len(vulns)}")
for vv in vulns[:3]:
print(" -", vv.get("id"), vv.get("summary","")[:120])
PYRepository: testsigmahq/testsigma-addons
Length of output: 1796
🏁 Script executed:
git ls-files | grep -E 'pom\.xml$' | head -20Repository: testsigmahq/testsigma-addons
Length of output: 1888
🌐 Web query:
Latest stable version of JUnit Jupiter (org.junit.jupiter:junit-jupiter-api)
💡 Result:
The latest stable version of org.junit.jupiter:junit-jupiter-api is 6.0.3, released on February 15, 2026.
Citations:
- 1: https://libraries.io/maven/org.junit.jupiter:junit-jupiter/versions
- 2: https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
- 3: https://docs.junit.org/6.0.3/release-notes.html
- 4: https://github.com/junit-team/junit5
- 5: https://github.com/junit-team/junit5/tags
🌐 Web query:
Latest stable version of TestNG (org.testng:testng)
💡 Result:
The latest stable version of TestNG (org.testng:testng) is 7.12.0.
Citations:
- 1: https://github.com/cbeust/testng
- 2: https://mvnrepository.com/artifact/org.testng/testng
- 3: https://github.com/testng-team/testng/releases/tag/7.12.0
- 4: https://libraries.io/maven/org.testng:testng
- 5: https://central.sonatype.com/artifact/org.testng/testng/7.12.0
- 6: https://github.com/testng-team/testng/tags
🌐 Web query:
Latest stable version of Selenium (org.seleniumhq.selenium:selenium-java)
💡 Result:
The latest stable version of org.seleniumhq.selenium:selenium-java is 4.43.0, released on April 10, 2026.
Citations:
- 1: https://github.com/SeleniumHQ/selenium/releases/tag/selenium-4.43.0
- 2: https://github.com/SeleniumHQ/selenium/blob/0157a05048/java/CHANGELOG
- 3: SeleniumHQ/selenium@dd0f534
- 4: https://central.sonatype.com/artifact/org.seleniumhq.selenium/selenium-java/4.43.0
- 5: https://github.com/seleniumHQ/selenium
🌐 Web query:
Latest stable version of Appium (io.appium:java-client)
💡 Result:
The latest stable version of io.appium:java-client is 10.1.1.
Citations:
- 1: https://github.com/appium/java-client/releases
- 2: https://mvnrepository.com/artifact/io.appium/java-client
- 3: https://central.sonatype.com/artifact/io.appium/java-client/10.1.1
- 4: https://github.com/appium/java-client/releases/tag/v9.5.0
🌐 Web query:
Latest stable version of Jackson Annotations (com.fasterxml.jackson.core:jackson-annotations)
💡 Result:
The latest stable version of Jackson Annotations (com.fasterxml.jackson.core:jackson-annotations) is 2.18.6.
Citations:
- 1: https://github.com/FasterXML/jackson-annotations/tags
- 2: https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations
- 3: https://mvnrepository.com/artifact/com.fasterxml.jackson.core
- 4: https://javadoc.io/doc/com.fasterxml.jackson.core/jackson-annotations/2.18.6/index.html
- 5: https://libraries.io/maven/com.fasterxml.jackson.core:jackson-annotations
Update pinned dependency versions before publishing as PUBLIC.
The version 5.8.0-M1 at line 17 is a JUnit Jupiter milestone build, not a stable release. Additionally, versions at lines 17, 45, 62, and 72 are significantly outdated:
junit-jupiter-api:5.8.0-M1→ latest:6.0.3(stable)testng:6.14.3→ latest:7.12.0selenium-java:4.14.1→ latest:4.43.0java-client:9.0.0→ latest:10.1.1jackson-annotations:2.13.0→ latest:2.18.6
Update to current stable versions and verify against known advisories before release.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@folder_and_file_actions_11365282608597864633118400917122709149/pom.xml` at
line 17, The pom declares outdated or milestone dependency versions (property
junit.jupiter.version and dependencies junit-jupiter-api, testng, selenium-java,
java-client, jackson-annotations); update junit.jupiter.version and the specific
dependency entries (junit-jupiter-api, testng, selenium-java, java-client,
jackson-annotations) to current stable releases (e.g., junit 6.0.3, testng
7.12.0, selenium 4.43.0, java-client 10.1.1, jackson-annotations 2.18.6) or your
approved versions, run a full build/test cycle to ensure compatibility, and
cross-check the updated versions against known security advisories before
publishing.
| <dependency> | ||
| <groupId>org.testng</groupId> | ||
| <artifactId>testng</artifactId> | ||
| <version>6.14.3</version> | ||
| </dependency> |
There was a problem hiding this comment.
Set TestNG to test scope to avoid shipping test framework in the addon JAR.
At Line 42, org.testng:testng is compile scope by default. With shading enabled, this can be bundled into the runtime artifact and increase conflict risk unnecessarily.
Suggested fix
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
+ <scope>test</scope>
</dependency>📝 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.
| <dependency> | |
| <groupId>org.testng</groupId> | |
| <artifactId>testng</artifactId> | |
| <version>6.14.3</version> | |
| </dependency> | |
| <dependency> | |
| <groupId>org.testng</groupId> | |
| <artifactId>testng</artifactId> | |
| <version>6.14.3</version> | |
| <scope>test</scope> | |
| </dependency> |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@folder_and_file_actions_11365282608597864633118400917122709149/pom.xml`
around lines 42 - 46, The TestNG dependency org.testng:testng is currently left
at default (compile) scope and will be packaged into the shaded addon JAR;
change the dependency declaration for groupId org.testng and artifactId testng
(version 6.14.3) to use test scope by adding a <scope>test</scope> element so
the test framework is excluded from the runtime artifact.
| Result result = Result.SUCCESS; | ||
| String folderPath = folderPath_.getValue().toString(); | ||
| String fileName = fileName_.getValue().toString(); | ||
| long size = Long.parseLong(size_.getValue().toString()); |
There was a problem hiding this comment.
Handle invalid size input safely.
Line 41 can throw NumberFormatException and terminate the action instead of returning a controlled FAILED result. Also reject negative sizes explicitly.
Proposed fix
- long size = Long.parseLong(size_.getValue().toString());
+ long size;
+ try {
+ size = Long.parseLong(String.valueOf(size_.getValue()).trim());
+ if (size < 0) {
+ setErrorMessage("Given size must be a non-negative number in KB");
+ return Result.FAILED;
+ }
+ } catch (RuntimeException e) {
+ setErrorMessage("Given size must be a non-negative number in KB");
+ 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.
| long size = Long.parseLong(size_.getValue().toString()); | |
| long size; | |
| try { | |
| size = Long.parseLong(String.valueOf(size_.getValue()).trim()); | |
| if (size < 0) { | |
| setErrorMessage("Given size must be a non-negative number in KB"); | |
| return Result.FAILED; | |
| } | |
| } catch (RuntimeException e) { | |
| setErrorMessage("Given size must be a non-negative number in KB"); | |
| return Result.FAILED; | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@folder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/web/IfVerifyFileWithNamePresenceWithFileSize.java`
at line 41, The parse of size_ in IfVerifyFileWithNamePresenceWithFileSize can
throw NumberFormatException or accept negative values; wrap the
Long.parseLong(size_.getValue().toString()) call in a try/catch that catches
NumberFormatException, log/set a clear error message and return a FAILED result
from the action, and after parsing explicitly check if size < 0 and likewise set
an error and return FAILED; update the method that contains the parse (the
execution flow around the size_ variable) to use the validated long value only
after these checks.
| } else { | ||
| result = Result.FAILED; | ||
| setErrorMessage(String.format(util.FOLDER_NOT_FOUND, folderPath)); | ||
| } |
There was a problem hiding this comment.
Use the correct file-not-found error in the null-file branch.
At Line 59, this branch means the folder exists but file lookup failed; using FOLDER_NOT_FOUND is misleading.
Proposed fix
- } else {
- result = Result.FAILED;
- setErrorMessage(String.format(util.FOLDER_NOT_FOUND, folderPath));
- }
+ } else {
+ result = Result.FAILED;
+ setErrorMessage(String.format(util.NO_FILE_EXISTS_ERROR_MSG, fileName, folderPath));
+ }📝 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.
| } else { | |
| result = Result.FAILED; | |
| setErrorMessage(String.format(util.FOLDER_NOT_FOUND, folderPath)); | |
| } | |
| } else { | |
| result = Result.FAILED; | |
| setErrorMessage(String.format(util.NO_FILE_EXISTS_ERROR_MSG, fileName, folderPath)); | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@folder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/web/IfVerifyFileWithNamePresenceWithFileSize.java`
around lines 59 - 62, In the null-file branch inside class
IfVerifyFileWithNamePresenceWithFileSize where you currently set result =
Result.FAILED and call setErrorMessage(String.format(util.FOLDER_NOT_FOUND,
folderPath)), replace the misleading util.FOLDER_NOT_FOUND usage with the
correct file-not-found constant (util.FILE_NOT_FOUND) and format the message
with the missing file identifier (e.g., fileName or the full file path) so
setErrorMessage reports the missing file; keep the Result.FAILED and
setErrorMessage call but swap the constant and argument to reference the file
rather than the folder.
| Result result = Result.SUCCESS; | ||
| String folderPath = folderPath_.getValue().toString(); | ||
| String fileName = fileName_.getValue().toString(); | ||
| long size = Long.parseLong(size_.getValue().toString()); |
There was a problem hiding this comment.
Guard size parsing and invalid values.
Line 41 can throw on non-numeric input and bypass normal action failure messaging. Return Result.FAILED with a validation message instead (and reject negative KB).
Proposed fix
- long size = Long.parseLong(size_.getValue().toString());
+ long size;
+ try {
+ size = Long.parseLong(String.valueOf(size_.getValue()).trim());
+ if (size < 0) {
+ setErrorMessage("Given size must be a non-negative number in KB");
+ return Result.FAILED;
+ }
+ } catch (RuntimeException e) {
+ setErrorMessage("Given size must be a non-negative number in KB");
+ return Result.FAILED;
+ }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@folder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/windowsAdvanced/IfVerifyFileWithNamePresenceWithFileSize.java`
at line 41, The direct call to Long.parseLong(size_.getValue().toString()) in
IfVerifyFileWithNamePresenceWithFileSize can throw NumberFormatException or
accept negative values; wrap the parse in a try/catch and validate the parsed
value: catch NumberFormatException and return Result.FAILED with a clear
validation message (e.g., "Invalid file size: must be a non-negative integer"),
and if the parsed long is negative also return Result.FAILED with a message
rejecting negative KB; keep references to the existing variable size_ and the
parse call (Long.parseLong) so the change is localized to that
parsing/validation block inside the class's action method.
| } else { | ||
| result = Result.FAILED; | ||
| setErrorMessage(String.format(util.FOLDER_NOT_FOUND, folderPath)); | ||
| } |
There was a problem hiding this comment.
Fix incorrect error template for missing file case.
At Line 59, folder existence is already confirmed (Line 47), so this should report file-not-found, not folder-not-found.
Proposed fix
- } else {
- result = Result.FAILED;
- setErrorMessage(String.format(util.FOLDER_NOT_FOUND, folderPath));
- }
+ } else {
+ result = Result.FAILED;
+ setErrorMessage(String.format(util.NO_FILE_EXISTS_ERROR_MSG, fileName, folderPath));
+ }📝 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.
| } else { | |
| result = Result.FAILED; | |
| setErrorMessage(String.format(util.FOLDER_NOT_FOUND, folderPath)); | |
| } | |
| } else { | |
| result = Result.FAILED; | |
| setErrorMessage(String.format(util.NO_FILE_EXISTS_ERROR_MSG, fileName, folderPath)); | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@folder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/windowsAdvanced/IfVerifyFileWithNamePresenceWithFileSize.java`
around lines 59 - 62, The code in IfVerifyFileWithNamePresenceWithFileSize
incorrectly sets the error message to util.FOLDER_NOT_FOUND after confirming the
folder exists; change the error path where result is set to Result.FAILED to use
the file-missing template instead by replacing util.FOLDER_NOT_FOUND with
util.FILE_NOT_FOUND in the setErrorMessage call (keep setting result =
Result.FAILED and leave surrounding logic unchanged).
| setErrorMessage(String.format("The files exists with containing name %s in the folder path %s and its" + | ||
| " size %s KB is not greater than %s KB", fileName, folderPath, fileSize, size)); |
There was a problem hiding this comment.
Fix user-facing message grammar.
Error text has typos (“files exists”, “with containing”). This appears in step results and should be corrected for clarity.
Proposed wording
- setErrorMessage(String.format("The files exists with containing name %s in the folder path %s and its" +
- " size %s KB is not greater than %s KB", fileName, folderPath, fileSize, size));
+ setErrorMessage(String.format("A file containing name %s exists in folder path %s, but its size %s KB is not greater than %s KB",
+ fileName, folderPath, fileSize, size));📝 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.
| setErrorMessage(String.format("The files exists with containing name %s in the folder path %s and its" + | |
| " size %s KB is not greater than %s KB", fileName, folderPath, fileSize, size)); | |
| setErrorMessage(String.format("A file containing name %s exists in folder path %s, but its size %s KB is not greater than %s KB", | |
| fileName, folderPath, fileSize, size)); |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@folder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/windowsAdvanced/VerifyFileContainingNamePresenceWithFileSize.java`
around lines 56 - 57, Update the user-facing error string in
VerifyFileContainingNamePresenceWithFileSize where setErrorMessage(...) is
called: replace the grammatically incorrect message ("The files exists with
containing name ...") with a clear sentence that references fileName,
folderPath, fileSize and size variables (for example: "A file containing '%s'
exists in folder '%s' but its size %s KB is not greater than %s KB"); ensure you
only change the message text in the setErrorMessage(String.format(...)) call so
the format specifiers and variables (fileName, folderPath, fileSize, size)
remain correct.
| Result result = Result.SUCCESS; | ||
| String folderPath = folderPath_.getValue().toString(); | ||
| String fileName = fileName_.getValue().toString(); | ||
| long size = Long.parseLong(size_.getValue().toString()); |
There was a problem hiding this comment.
Validate test-data size before use.
Line 39 currently assumes valid numeric input; invalid/negative values should produce controlled FAILED with a clear message instead of runtime failure.
Proposed fix
- long size = Long.parseLong(size_.getValue().toString());
+ long size;
+ try {
+ size = Long.parseLong(String.valueOf(size_.getValue()).trim());
+ if (size < 0) {
+ setErrorMessage("Given size must be a non-negative number in KB");
+ return Result.FAILED;
+ }
+ } catch (RuntimeException e) {
+ setErrorMessage("Given size must be a non-negative number in KB");
+ 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.
| long size = Long.parseLong(size_.getValue().toString()); | |
| long size; | |
| try { | |
| size = Long.parseLong(String.valueOf(size_.getValue()).trim()); | |
| if (size < 0) { | |
| setErrorMessage("Given size must be a non-negative number in KB"); | |
| return Result.FAILED; | |
| } | |
| } catch (RuntimeException e) { | |
| setErrorMessage("Given size must be a non-negative number in KB"); | |
| return Result.FAILED; | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@folder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/windowsAdvanced/VerifyFileWithNamePresenceWithFileSize.java`
at line 39, The code directly calls Long.parseLong on size_.getValue() and
assumes it's a valid non-negative number; wrap the parse in a try/catch to catch
NumberFormatException and also validate that the parsed long (the variable size)
is >= 0, and if either check fails set the step/result to FAILED with a clear
message (e.g., "Invalid test-data size: '<value>'" or "Negative size not
allowed: <value>") and return early; update the logic in class
VerifyFileWithNamePresenceWithFileSize around the
Long.parseLong(size_.getValue().toString()) usage so invalid or negative inputs
produce a controlled FAILED result instead of throwing.
| } else { | ||
| result = Result.FAILED; | ||
| setErrorMessage(String.format(util.FOLDER_NOT_FOUND, folderPath)); | ||
| } |
There was a problem hiding this comment.
Incorrect failure reason in file-not-found branch.
At Line 57, this branch should report missing file (NO_FILE_EXISTS_ERROR_MSG) since folder existence was already confirmed at Line 45.
Proposed fix
- } else {
- result = Result.FAILED;
- setErrorMessage(String.format(util.FOLDER_NOT_FOUND, folderPath));
- }
+ } else {
+ result = Result.FAILED;
+ setErrorMessage(String.format(util.NO_FILE_EXISTS_ERROR_MSG, fileName, folderPath));
+ }📝 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.
| } else { | |
| result = Result.FAILED; | |
| setErrorMessage(String.format(util.FOLDER_NOT_FOUND, folderPath)); | |
| } | |
| } else { | |
| result = Result.FAILED; | |
| setErrorMessage(String.format(util.NO_FILE_EXISTS_ERROR_MSG, fileName, folderPath)); | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@folder_and_file_actions_11365282608597864633118400917122709149/src/main/java/com/testsigma/addons/windowsAdvanced/VerifyFileWithNamePresenceWithFileSize.java`
around lines 57 - 60, In the file-not-found branch inside
VerifyFileWithNamePresenceWithFileSize, replace the incorrect
util.FOLDER_NOT_FOUND error message with the file-missing constant
util.NO_FILE_EXISTS_ERROR_MSG (and include the target file identifier, e.g.,
fileName or expected file path variable) so setErrorMessage(...) reports the
missing file rather than a missing folder; update the setErrorMessage call in
that else branch to use util.NO_FILE_EXISTS_ERROR_MSG and format it with the
file identifier.
please review this addon and publish as PUBLIC
Addon name : Folder and File Actions
Addon accont: https://jarvis.testsigma.com/ui/tenants/2817/addons
Jira: https://testsigma.atlassian.net/browse/CUS-12422
fix
Summary by CodeRabbit
New Features