feat/CUS-10696-Added class to concatenate two strings with special chars and store it in runtime variable#336
Conversation
…t in runtime variable
📝 WalkthroughWalkthroughA new Maven-based Java addon project is introduced with platform-specific string concatenation implementations. The project includes configuration files (pom.xml, properties) and seven nearly identical StringConcatenate action classes targeting Android, iOS, Web, MobileWeb, REST API, Salesforce, and Windows platforms. Each action concatenates two input strings with configurable separators and stores results in runtime variables. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 11
🧹 Nitpick comments (5)
concatenate_and_store_string/src/main/java/com/testsigma/addons/ios/StringConcatenate.java (1)
6-6: Unused importWebAction.This class extends
IOSAction, notWebAction. This import appears to be a copy-paste artifact from the Web variant.Proposed fix
-import com.testsigma.sdk.WebAction;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@concatenate_and_store_string/src/main/java/com/testsigma/addons/ios/StringConcatenate.java` at line 6, Remove the unused import of WebAction which is a leftover from the web variant; since this class extends IOSAction (class name StringConcatenate), delete the WebAction import line to avoid unused-import warnings and keep imports relevant to StringConcatenate/IOSAction.concatenate_and_store_string/src/main/java/com/testsigma/addons/restapi/StringConcatenate.java (1)
6-6: Unused importWebAction.This class extends
RestApiAction, so theWebActionimport is a copy-paste leftover.Proposed fix
-import com.testsigma.sdk.WebAction;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@concatenate_and_store_string/src/main/java/com/testsigma/addons/restapi/StringConcatenate.java` at line 6, Remove the unused import com.testsigma.sdk.WebAction from the top of the file — it's a leftover from copy/paste and not used by the StringConcatenate class (which extends RestApiAction); open the class StringConcatenate and delete the WebAction import so only the necessary imports remain.concatenate_and_store_string/src/main/java/com/testsigma/addons/android/StringConcatenate.java (2)
6-6: Unused importWebAction.This class extends
AndroidAction, so theWebActionimport is a copy-paste leftover.Proposed fix
-import com.testsigma.sdk.WebAction;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@concatenate_and_store_string/src/main/java/com/testsigma/addons/android/StringConcatenate.java` at line 6, Remove the unused import statement for WebAction: in the StringConcatenate class (which extends AndroidAction) delete the line importing com.testsigma.sdk.WebAction to eliminate the unused copy-paste leftover and keep imports minimal.
34-65: Extract shared concatenation logic into a single utility method.The
execute()body is copy-pasted verbatim across all 7 platform classes (Android, iOS, MobileWeb, Web, REST API, Salesforce, Windows). Any bug fix — like thesplit("space")issue — must be replicated in every file. Consider extracting the concatenation + runtime-storage logic into a shared static helper (e.g.,StringConcatenateHelper.concatenate(...)) that each platform class delegates to. This keeps each platform class as a thin adapter.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@concatenate_and_store_string/src/main/java/com/testsigma/addons/android/StringConcatenate.java` around lines 34 - 65, Extract the concatenation and runtime-storage logic from execute() into a shared static helper (e.g., StringConcatenateHelper.concatenate) that takes the three input strings (values from testDataString1, testDataString2, testDataString3) plus the variableName and runTimeData setter callbacks, performs the space parsing and concatenation (fixing the split("space") fragility by parsing the numeric suffix robustly), returns success/failure and the resulting string, and moves logging/error-message setting (logger.info, setSuccessMessage, setErrorMessage) into the helper or returns enough info for the caller to do so; then replace the platform-specific bodies (methods named execute in Android/iOS/MobileWeb/Web/RestApi/Salesforce/Windows classes) to simply call StringConcatenateHelper.concatenate(...) and handle the Result return.concatenate_and_store_string/src/main/java/com/testsigma/addons/salesforce/StringConcatenate.java (1)
6-6: Unused importWebAction.This class extends
SalesforceAction, so theWebActionimport on line 6 is a copy-paste leftover and can be removed.Proposed fix
-import com.testsigma.sdk.WebAction;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@concatenate_and_store_string/src/main/java/com/testsigma/addons/salesforce/StringConcatenate.java` at line 6, Remove the unused import of WebAction from StringConcatenate.java: locate the import statement "import com.testsigma.sdk.WebAction;" and delete it since StringConcatenate extends SalesforceAction and does not reference WebAction; ensure no other code references WebAction and run a quick compile to verify no missing symbols.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@concatenate_and_store_string/pom.xml`:
- Around line 42-46: The TestNG dependency block (artifactId "testng", version
"6.14.3") is missing a test scope and will be included in the production jar;
update the dependency declaration to add <scope>test</scope> so TestNG is only
used for tests and not shaded into the production artifact (modify the
dependency entry for artifactId "testng" accordingly).
In
`@concatenate_and_store_string/src/main/java/com/testsigma/addons/ios/StringConcatenate.java`:
- Around line 47-49: The code in class StringConcatenate currently uses
input.split("space")[1], which crashes on inputs like "space" because split
returns an empty array; change the logic in StringConcatenate to validate the
input format before accessing the second element (or use a regex to extract the
numeric portion), and return or throw a clear validation error (e.g., "invalid
input: expected 'space <number>'") instead of letting the generic catch produce
"Error while concatenating both strings"; specifically update the block that
references split(...) and the exception handling to check array length (or
pattern match with Pattern/Matcher) and provide a precise fallback/error
message.
- Around line 56-57: In class StringConcatenate, fix the user-facing typo by
replacing every occurrence of "RuntTime" with "RunTime" in log and result
messages (search for "RuntTime" in StringConcatenate.java and update the strings
used in logger/error messages and the success/failure message returned to the
caller); ensure both the log call and the success message strings now read
"RunTime" so user-facing output is correct.
- Around line 45-51: The conditional checks using contains("none") and
contains("space") in StringConcatenate are too broad and cause false matches;
update those checks to use equals("none") and equals("space") for exact matching
(or if the intent for the "space" branch is to match prefixes use
startsWith("space") instead). Locate the occurrences of contains("none") and
contains("space") in the StringConcatenate class (the method handling the input
selection) and replace them accordingly so only exact (or explicit prefix)
matches trigger each branch.
In
`@concatenate_and_store_string/src/main/java/com/testsigma/addons/mobileweb/StringConcatenate.java`:
- Around line 55-56: Fix the "RuntTime" typo to "RunTime" in the log and success
messages inside the StringConcatenate class: update the logger.info(...) and
setSuccessMessage(...) calls (which build the message using
variableName.getValue().toString() and testdata3) to use "RunTime" instead of
"RuntTime"; apply the same change across the other six platform files that
contain the identical messages so all logs and success messages are consistent.
- Around line 46-48: The code in StringConcatenate.java (and its 7 platform
copies) unsafely uses strSpecChar.split("space")[1] and Integer.parseInt which
throws when input is exactly "space" or contains non-numeric suffixes; update
the logic in the method that builds testdata3 (reference symbol: testdata3,
string1, string2, strSpecChar) to validate and extract the repeat count safely:
check strSpecChar startsWith("space"), extract the substring after "space", if
empty default to 1, otherwise validate it contains only digits (or use a regex
like "^space(\\d+)$") then parseInt inside a try/catch and fallback to a safe
default on parse failure; apply the same change to all 7 copies so inputs like
"space", "space2", and invalid values no longer throw
ArrayIndexOutOfBoundsException/NumberFormatException.
- Around line 40-41: The code lowercases the entire separator string in
strSpecChar, which corrupts user-provided separators (e.g., "ABC" -> "abc");
change the logic in StringConcatenate (around the variables
strSpecChar/testdata3 and the branch that handles separators) to preserve the
original separator value for concatenation by introducing a raw variable (e.g.,
specCharRaw = testDataString3.getValue().toString().trim()) and only use a
lowercased version (e.g., specChar = specCharRaw.toLowerCase()) for comparisons
against "none"/"space"; then use specCharRaw in the else branch when building
the concatenated string so the original separator case is retained.
In
`@concatenate_and_store_string/src/main/java/com/testsigma/addons/windows/StringConcatenate.java`:
- Around line 3-6: Remove the unused import WebAction from the top of
StringConcatenate.java; the class StringConcatenate extends WindowsAction so
WebAction is unnecessary—delete the line that imports
com.testsigma.sdk.WebAction to clean up imports and avoid IDE/compiler warnings.
- Around line 56-57: Typo "RuntTime" should be corrected to "RunTime" in the log
and success text; update the string literals used in the logger.info(...) and
setSuccessMessage(...) calls (refer to the StringConcatenate class where
logger.info("Successfully stored into RuntTime variable. " +
variableName.getValue().toString() + " = " + testdata3) and
setSuccessMessage(...) are called) so both messages read "Successfully stored
into RunTime variable. ...".
- Around line 44-51: The branching logic in StringConcatenate is unsafe: replace
strSpecChar.contains(...) checks with exact keyword matching
(strSpecChar.equals("none")) and use startsWith("space") for the space-prefix
case so unrelated strings (e.g., "namespace") don't match; do not call
toLowerCase() on the user-supplied delimiter value—only apply case normalization
to a temporary keyword when comparing so the actual delimiter used in
concatenation (strSpecChar) remains unchanged; validate the space count before
calling Integer.parseInt (ensure the suffix after "space" is non-empty and a
non-negative integer) and handle invalid formats with a clear error message
(e.g., "Invalid space count in delimiter") rather than the generic "Error while
concatenating both strings"; update uses of string1, string2, strSpace, and
testdata3 accordingly.
In `@concatenate_and_store_string/src/main/resources/testsigma-sdk.properties`:
- Line 1: The committed secret is the property testsigma-sdk.api.key in
testsigma-sdk.properties; remove the actual JWT from that file and replace it
with a placeholder or delete the file, rotate/invalidate the leaked key
immediately, and update the code to load the API key from a secure source such
as an environment variable (e.g. TESTSIGMA_API_KEY) or a secrets manager instead
of from the properties file; add testsigma-sdk.properties to .gitignore so it
isn’t re-committed, and purge the secret from git history using a
history-rewrite tool (git filter-repo or BFG) and force-push the cleaned branch
after rotation.
---
Duplicate comments:
In
`@concatenate_and_store_string/src/main/java/com/testsigma/addons/android/StringConcatenate.java`:
- Around line 1-66: The execute() method mishandles the special-char input:
calling toLowerCase() on testDataString3 will corrupt non-alphabetic separators,
and using strSpecChar.split("space")[1] will throw if no numeric suffix is
present; also the log/success messages contain a "RuntTime" typo. Fix by: read
raw value = testDataString3.getValue().toString().trim() (do not toLowerCase the
whole string), check the "none" case using a case-insensitive compare (e.g.,
equalsIgnoreCase on the original or a lower-cased copy only for the comparison),
detect the "space" pattern with a safe regex (e.g., match
"^\\s*space(\\d*)\\s*$") and parse the captured digits defaulting to 1 (or 0) if
absent, then build testdata3 accordingly; update logger.info and
setSuccessMessage text to "Runtime" (correct spelling) when calling
runTimeData.setKey(...) and setValue(...). Ensure all references: execute(),
testDataString3, testDataString1/2, runTimeData.setValue, runTimeData.setKey,
logger.info, setSuccessMessage are updated.
In
`@concatenate_and_store_string/src/main/java/com/testsigma/addons/restapi/StringConcatenate.java`:
- Around line 1-66: The code in execute() mis-handles the testdata specifier:
calling strSpecChar.toLowerCase() and then split("space")[1] can crash or
corrupt separators (e.g. "@" or "$") and the log/messages contain a "RuntTime"
typo; fix by only normalizing the keyword check (e.g. use a lowercased local
copy like specLower = testDataString3.getValue().toString().trim(); then compare
specLower.equalsIgnoreCase("none") or specLower.startsWith("space") without
altering the original separator), validate that specLower startsWith("space")
and that the numeric part exists and is a valid integer before parsing to avoid
ArrayIndexOutOfBounds/NumberFormatException, and correct the message text from
"RuntTime" to "RunTime" in logger.info and setSuccessMessage; update references
to strSpecChar, testdata3, runTimeData, and variableName in these changes.
In
`@concatenate_and_store_string/src/main/java/com/testsigma/addons/salesforce/StringConcatenate.java`:
- Around line 1-66: The execute() method in StringConcatenate has the same bugs
as the mobileweb variant: using strSpecChar.toLowerCase() mutates the exact
separator (fix by using a separate normalized variable for matching), calling
strSpecChar.split("space")[1] can throw if format is wrong (validate with
startsWith("space") and safe parsing of the integer or use a regex to extract
digits), and the log/setSuccessMessage text contains a "RuntTime" typo. Update
execute() to (1) create a normalized variable like specLower =
testDataString3.getValue().toString().trim().toLowerCase() for conditional
checks while preserving the original separator string for concatenation, (2)
when handling the "spaceN" case ensure specLower startsWith("space") then parse
the number safely (handle NumberFormatException and default or fail gracefully)
instead of blind split("space")[1], and (3) fix the typo in logger.info and
setSuccessMessage to "Runtime". Target symbols: class StringConcatenate, method
execute(), variables testDataString3/strSpecChar/specLower, testdata3,
runTimeData, logger, setSuccessMessage.
In
`@concatenate_and_store_string/src/main/java/com/testsigma/addons/web/StringConcatenate.java`:
- Around line 44-51: The branch logic using strSpecChar incorrectly relies on
contains() and unnormalized casing and parses integers without validation; in
the StringConcatenate logic (variables: strSpecChar, string1, string2,
testdata3, strSpace.repeat) normalize strSpecChar to lower-case once, avoid
using contains() for prefix/suffix checks (use equals() or startsWith("space")),
safely parse the space count after validating the substring (e.g., ensure the
part after "space" is numeric and > =0) and fall back to the delimiter as-is for
other cases; update the "none", "spaceN" and default branches accordingly so
string concatenation uses validated repeat counts and correct delimiter
handling.
- Around line 55-56: Fix the repeated typo "RuntTime" in the success messages
inside StringConcatenate (the logger.info and setSuccessMessage calls) by
replacing "RuntTime" with the correct "Runtime" so both messages read
"Successfully stored into Runtime variable. " +
variableName.getValue().toString() + " = " + testdata3; locate these calls in
the StringConcatenate class and update the string literal used in logger.info
and setSuccessMessage.
---
Nitpick comments:
In
`@concatenate_and_store_string/src/main/java/com/testsigma/addons/android/StringConcatenate.java`:
- Line 6: Remove the unused import statement for WebAction: in the
StringConcatenate class (which extends AndroidAction) delete the line importing
com.testsigma.sdk.WebAction to eliminate the unused copy-paste leftover and keep
imports minimal.
- Around line 34-65: Extract the concatenation and runtime-storage logic from
execute() into a shared static helper (e.g.,
StringConcatenateHelper.concatenate) that takes the three input strings (values
from testDataString1, testDataString2, testDataString3) plus the variableName
and runTimeData setter callbacks, performs the space parsing and concatenation
(fixing the split("space") fragility by parsing the numeric suffix robustly),
returns success/failure and the resulting string, and moves
logging/error-message setting (logger.info, setSuccessMessage, setErrorMessage)
into the helper or returns enough info for the caller to do so; then replace the
platform-specific bodies (methods named execute in
Android/iOS/MobileWeb/Web/RestApi/Salesforce/Windows classes) to simply call
StringConcatenateHelper.concatenate(...) and handle the Result return.
In
`@concatenate_and_store_string/src/main/java/com/testsigma/addons/ios/StringConcatenate.java`:
- Line 6: Remove the unused import of WebAction which is a leftover from the web
variant; since this class extends IOSAction (class name StringConcatenate),
delete the WebAction import line to avoid unused-import warnings and keep
imports relevant to StringConcatenate/IOSAction.
In
`@concatenate_and_store_string/src/main/java/com/testsigma/addons/restapi/StringConcatenate.java`:
- Line 6: Remove the unused import com.testsigma.sdk.WebAction from the top of
the file — it's a leftover from copy/paste and not used by the StringConcatenate
class (which extends RestApiAction); open the class StringConcatenate and delete
the WebAction import so only the necessary imports remain.
In
`@concatenate_and_store_string/src/main/java/com/testsigma/addons/salesforce/StringConcatenate.java`:
- Line 6: Remove the unused import of WebAction from StringConcatenate.java:
locate the import statement "import com.testsigma.sdk.WebAction;" and delete it
since StringConcatenate extends SalesforceAction and does not reference
WebAction; ensure no other code references WebAction and run a quick compile to
verify no missing symbols.
| <dependency> | ||
| <groupId>org.testng</groupId> | ||
| <artifactId>testng</artifactId> | ||
| <version>6.14.3</version> | ||
| </dependency> |
There was a problem hiding this comment.
testng dependency is missing <scope>test</scope>.
Without test scope, TestNG will be bundled into the shaded production jar, bloating the artifact and potentially causing classpath conflicts at runtime.
Proposed fix
<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 `@concatenate_and_store_string/pom.xml` around lines 42 - 46, The TestNG
dependency block (artifactId "testng", version "6.14.3") is missing a test scope
and will be included in the production jar; update the dependency declaration to
add <scope>test</scope> so TestNG is only used for tests and not shaded into the
production artifact (modify the dependency entry for artifactId "testng"
accordingly).
| if (strSpecChar.contains("none")) { | ||
| testdata3 = string1 + string2; | ||
| } else if (strSpecChar.contains("space")) { | ||
| Integer spaceCount = Integer.parseInt(strSpecChar.split("space")[1]); | ||
| testdata3 = string1 + strSpace.repeat(spaceCount) + string2; | ||
| } else { | ||
| testdata3 = string1 + strSpecChar + string2; |
There was a problem hiding this comment.
contains() should be equals() to prevent false matches.
contains("none") matches inputs like "nonexistent", and contains("space") matches "namespace" or "myspace". Use equals for exact matching (or startsWith for the "space" branch if you want to keep the prefix pattern).
Proposed fix
- if (strSpecChar.contains("none")) {
+ if (strSpecChar.equals("none")) {
testdata3 = string1 + string2;
- } else if (strSpecChar.contains("space")) {
+ } else if (strSpecChar.startsWith("space")) {
Integer spaceCount = Integer.parseInt(strSpecChar.split("space")[1]);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@concatenate_and_store_string/src/main/java/com/testsigma/addons/ios/StringConcatenate.java`
around lines 45 - 51, The conditional checks using contains("none") and
contains("space") in StringConcatenate are too broad and cause false matches;
update those checks to use equals("none") and equals("space") for exact matching
(or if the intent for the "space" branch is to match prefixes use
startsWith("space") instead). Locate the occurrences of contains("none") and
contains("space") in the StringConcatenate class (the method handling the input
selection) and replace them accordingly so only exact (or explicit prefix)
matches trigger each branch.
| } else if (strSpecChar.contains("space")) { | ||
| Integer spaceCount = Integer.parseInt(strSpecChar.split("space")[1]); | ||
| testdata3 = string1 + strSpace.repeat(spaceCount) + string2; |
There was a problem hiding this comment.
"space" (without a number) causes an unhandled crash path.
In Java, "space".split("space") returns an empty array, so accessing [1] throws ArrayIndexOutOfBoundsException. While this is caught by the generic catch, the resulting error message ("Error while concatenating both strings") is confusing for a simple input validation issue. Consider validating the format or using a regex to extract the digit portion with a clearer fallback.
Proposed fix using substring
- Integer spaceCount = Integer.parseInt(strSpecChar.split("space")[1]);
+ String countPart = strSpecChar.substring("space".length());
+ if (countPart.isEmpty()) {
+ throw new IllegalArgumentException("Space count not specified. Use 'space1', 'space2', etc.");
+ }
+ int spaceCount = Integer.parseInt(countPart);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@concatenate_and_store_string/src/main/java/com/testsigma/addons/ios/StringConcatenate.java`
around lines 47 - 49, The code in class StringConcatenate currently uses
input.split("space")[1], which crashes on inputs like "space" because split
returns an empty array; change the logic in StringConcatenate to validate the
input format before accessing the second element (or use a regex to extract the
numeric portion), and return or throw a clear validation error (e.g., "invalid
input: expected 'space <number>'") instead of letting the generic catch produce
"Error while concatenating both strings"; specifically update the block that
references split(...) and the exception handling to check array length (or
pattern match with Pattern/Matcher) and provide a precise fallback/error
message.
| logger.info("Successfully stored into RuntTime variable. " + variableName.getValue().toString() + " = " + testdata3); | ||
| setSuccessMessage("Successfully stored into RuntTime variable. " + variableName.getValue().toString() + " = " + testdata3); |
There was a problem hiding this comment.
Typo: "RuntTime" → "RunTime" in user-facing messages.
This typo appears in both the log message and the success message.
Proposed fix
- logger.info("Successfully stored into RuntTime variable. " + variableName.getValue().toString() + " = " + testdata3);
- setSuccessMessage("Successfully stored into RuntTime variable. " + variableName.getValue().toString() + " = " + testdata3);
+ logger.info("Successfully stored into RunTime variable. " + variableName.getValue().toString() + " = " + testdata3);
+ setSuccessMessage("Successfully stored into RunTime variable. " + variableName.getValue().toString() + " = " + testdata3);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@concatenate_and_store_string/src/main/java/com/testsigma/addons/ios/StringConcatenate.java`
around lines 56 - 57, In class StringConcatenate, fix the user-facing typo by
replacing every occurrence of "RuntTime" with "RunTime" in log and result
messages (search for "RuntTime" in StringConcatenate.java and update the strings
used in logger/error messages and the success/failure message returned to the
caller); ensure both the log call and the success message strings now read
"RunTime" so user-facing output is correct.
| String strSpecChar = testDataString3.getValue().toString().toLowerCase().trim(); | ||
| String testdata3= ""; |
There was a problem hiding this comment.
toLowerCase() silently alters the separator character.
Line 40 lowercases the entire testdata input to match "none" / "space", but this also lowercases the actual separator when it falls through to the else branch (line 50). If a user passes "ABC" as a separator, it becomes "abc". Consider only lowercasing for the comparison, not the value used for concatenation.
Proposed fix
- String strSpecChar = testDataString3.getValue().toString().toLowerCase().trim();
+ String rawSpecChar = testDataString3.getValue().toString().trim();
+ String strSpecCharLower = rawSpecChar.toLowerCase();
...
- if (strSpecChar.contains("none")) {
+ if (strSpecCharLower.contains("none")) {
testdata3 = string1 + string2;
- } else if (strSpecChar.contains("space")) {
- Integer spaceCount = Integer.parseInt(strSpecChar.split("space")[1]);
+ } else if (strSpecCharLower.contains("space")) {
+ String[] parts = strSpecCharLower.split("space");
+ int spaceCount = (parts.length > 1 && !parts[1].isEmpty())
+ ? Integer.parseInt(parts[1].trim()) : 1;
testdata3 = string1 + strSpace.repeat(spaceCount) + string2;
} else {
- testdata3 = string1 + strSpecChar + string2;
+ testdata3 = string1 + rawSpecChar + string2;
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@concatenate_and_store_string/src/main/java/com/testsigma/addons/mobileweb/StringConcatenate.java`
around lines 40 - 41, The code lowercases the entire separator string in
strSpecChar, which corrupts user-provided separators (e.g., "ABC" -> "abc");
change the logic in StringConcatenate (around the variables
strSpecChar/testdata3 and the branch that handles separators) to preserve the
original separator value for concatenation by introducing a raw variable (e.g.,
specCharRaw = testDataString3.getValue().toString().trim()) and only use a
lowercased version (e.g., specChar = specCharRaw.toLowerCase()) for comparisons
against "none"/"space"; then use specCharRaw in the else branch when building
the concatenated string so the original separator case is retained.
| logger.info("Successfully stored into RuntTime variable. " + variableName.getValue().toString() + " = " + testdata3); | ||
| setSuccessMessage("Successfully stored into RuntTime variable. " + variableName.getValue().toString() + " = " + testdata3); |
There was a problem hiding this comment.
Typo: "RuntTime" → "RunTime".
Present in both the log message and the success message. Same typo exists in all 7 platform files.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@concatenate_and_store_string/src/main/java/com/testsigma/addons/mobileweb/StringConcatenate.java`
around lines 55 - 56, Fix the "RuntTime" typo to "RunTime" in the log and
success messages inside the StringConcatenate class: update the logger.info(...)
and setSuccessMessage(...) calls (which build the message using
variableName.getValue().toString() and testdata3) to use "RunTime" instead of
"RuntTime"; apply the same change across the other six platform files that
contain the identical messages so all logs and success messages are consistent.
| import com.testsigma.sdk.ApplicationType; | ||
| import com.testsigma.sdk.Result; | ||
| import com.testsigma.sdk.WebAction; | ||
| import com.testsigma.sdk.WindowsAction; |
There was a problem hiding this comment.
Unused import WebAction.
WebAction is imported but the class extends WindowsAction. Remove the unused import.
Proposed fix
import com.testsigma.sdk.ApplicationType;
import com.testsigma.sdk.Result;
-import com.testsigma.sdk.WebAction;
import com.testsigma.sdk.WindowsAction;📝 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.
| import com.testsigma.sdk.ApplicationType; | |
| import com.testsigma.sdk.Result; | |
| import com.testsigma.sdk.WebAction; | |
| import com.testsigma.sdk.WindowsAction; | |
| import com.testsigma.sdk.ApplicationType; | |
| import com.testsigma.sdk.Result; | |
| import com.testsigma.sdk.WindowsAction; |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@concatenate_and_store_string/src/main/java/com/testsigma/addons/windows/StringConcatenate.java`
around lines 3 - 6, Remove the unused import WebAction from the top of
StringConcatenate.java; the class StringConcatenate extends WindowsAction so
WebAction is unnecessary—delete the line that imports
com.testsigma.sdk.WebAction to clean up imports and avoid IDE/compiler warnings.
|
|
||
| if (strSpecChar.contains("none")) { | ||
| testdata3 = string1 + string2; | ||
| } else if (strSpecChar.contains("space")) { | ||
| Integer spaceCount = Integer.parseInt(strSpecChar.split("space")[1]); | ||
| testdata3 = string1 + strSpace.repeat(spaceCount) + string2; | ||
| } else { | ||
| testdata3 = string1 + strSpecChar + string2; |
There was a problem hiding this comment.
contains() causes incorrect branch matching; toLowerCase() silently corrupts custom delimiters.
Three issues in this block:
-
contains("none")/contains("space"): Usingcontainsinstead ofequalsmeans inputs like"noneofyourbusiness"or"namespace"will match unintended branches. Useequals(orstartsWithfor the"space"prefix pattern). -
toLowerCase()on Line 41 alters user-supplied delimiters: If a user provides an uppercase delimiter (e.g.,"AND"), it becomes"and". The lowercasing should only apply to the keyword matching, not to the delimiter value used in concatenation. -
Line 48 —
Integer.parseInton unvalidated input:"space"without a trailing number yields"", and"space-1"yields-1which throwsIllegalArgumentExceptionfromString.repeat(). While the catch block handles it, the error message ("Error while concatenating both strings") is misleading — it's actually a bad input format.
Proposed fix
- String strSpecChar = testDataString3.getValue().toString().toLowerCase().trim();
+ String strSpecChar = testDataString3.getValue().toString().trim();
+ String strSpecCharLower = strSpecChar.toLowerCase();
String testdata3= "";
String strSpace=" ";
- if (strSpecChar.contains("none")) {
+ if (strSpecCharLower.equals("none")) {
testdata3 = string1 + string2;
- } else if (strSpecChar.contains("space")) {
- Integer spaceCount = Integer.parseInt(strSpecChar.split("space")[1]);
+ } else if (strSpecCharLower.startsWith("space")) {
+ String numPart = strSpecCharLower.substring("space".length());
+ int spaceCount = Integer.parseInt(numPart);
+ if (spaceCount < 1) {
+ throw new IllegalArgumentException("Space count must be >= 1, got: " + spaceCount);
+ }
testdata3 = string1 + strSpace.repeat(spaceCount) + string2;
} else {
testdata3 = string1 + strSpecChar + string2;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@concatenate_and_store_string/src/main/java/com/testsigma/addons/windows/StringConcatenate.java`
around lines 44 - 51, The branching logic in StringConcatenate is unsafe:
replace strSpecChar.contains(...) checks with exact keyword matching
(strSpecChar.equals("none")) and use startsWith("space") for the space-prefix
case so unrelated strings (e.g., "namespace") don't match; do not call
toLowerCase() on the user-supplied delimiter value—only apply case normalization
to a temporary keyword when comparing so the actual delimiter used in
concatenation (strSpecChar) remains unchanged; validate the space count before
calling Integer.parseInt (ensure the suffix after "space" is non-empty and a
non-negative integer) and handle invalid formats with a clear error message
(e.g., "Invalid space count in delimiter") rather than the generic "Error while
concatenating both strings"; update uses of string1, string2, strSpace, and
testdata3 accordingly.
| logger.info("Successfully stored into RuntTime variable. " + variableName.getValue().toString() + " = " + testdata3); | ||
| setSuccessMessage("Successfully stored into RuntTime variable. " + variableName.getValue().toString() + " = " + testdata3); |
There was a problem hiding this comment.
Typo: "RuntTime" should be "RunTime".
Appears in both the log message and success message.
Proposed fix
- logger.info("Successfully stored into RuntTime variable. " + variableName.getValue().toString() + " = " + testdata3);
- setSuccessMessage("Successfully stored into RuntTime variable. " + variableName.getValue().toString() + " = " + testdata3);
+ logger.info("Successfully stored into RunTime variable. " + variableName.getValue().toString() + " = " + testdata3);
+ setSuccessMessage("Successfully stored into RunTime variable. " + variableName.getValue().toString() + " = " + testdata3);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@concatenate_and_store_string/src/main/java/com/testsigma/addons/windows/StringConcatenate.java`
around lines 56 - 57, Typo "RuntTime" should be corrected to "RunTime" in the
log and success text; update the string literals used in the logger.info(...)
and setSuccessMessage(...) calls (refer to the StringConcatenate class where
logger.info("Successfully stored into RuntTime variable. " +
variableName.getValue().toString() + " = " + testdata3) and
setSuccessMessage(...) are called) so both messages read "Successfully stored
into RunTime variable. ...".
| @@ -0,0 +1 @@ | |||
| testsigma-sdk.api.key=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyMjMyMmM2Ni04NWYzLWIyN2UtN2FiOS0zM2U2M2Q4OWM1MGIiLCJ1bmlxdWVJZCI6IjU5NjEiLCJpZGVudGl0eUFjY291bnRVVUlkIjoiMzUifQ.XA9K2Lp9ZwqVlrXB5cyJTIZWkiC_uujedvauPE4UlHGg4I1GS3ScG5OtigTWqm_uU8Ux0E16k5c_TfgLHvVnYg No newline at end of file | |||
There was a problem hiding this comment.
Secret/API key committed to source control.
A JWT API key is checked into the repository. The PR description explicitly states this addon will be published publicly, which means this key will be exposed to anyone. Even after removal, it will persist in git history.
Rotate this key immediately and remove it from source. Use environment variables or a secrets manager instead, and add this file to .gitignore.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@concatenate_and_store_string/src/main/resources/testsigma-sdk.properties` at
line 1, The committed secret is the property testsigma-sdk.api.key in
testsigma-sdk.properties; remove the actual JWT from that file and replace it
with a placeholder or delete the file, rotate/invalidate the leaked key
immediately, and update the code to load the API key from a secure source such
as an environment variable (e.g. TESTSIGMA_API_KEY) or a secrets manager instead
of from the properties file; add testsigma-sdk.properties to .gitignore so it
isn’t re-committed, and purge the secret from git history using a
history-rewrite tool (git filter-repo or BFG) and force-push the cleaned branch
after rotation.
Publish this addon as public
Addon Name: Concatenate and Store String
Jarvis Link: https://jarvis.testsigma.com/ui/tenants/2817/addons
Addon ticket: https://testsigma.atlassian.net/browse/CUS-10696
Added class to concatenate two strings with special chars and store it in runtime variable
Summary by CodeRabbit