Skip to content

feat/CUS-11035-Migrated the classes to other applications - #350

Merged
akhil-testsigma merged 1 commit into
devfrom
feat/CUS-11035-Migrated-the-classes-to-other-applications
Mar 4, 2026
Merged

akhil-testsigma merged 1 commit into
devfrom
feat/CUS-11035-Migrated-the-classes-to-other-applications

Conversation

@akhil-testsigma

@akhil-testsigma akhil-testsigma commented Mar 3, 2026 •

Copy link
Copy Markdown
Contributor

Publish this addon as PUBLIC

Addon Name: MongoDB_NLPs
Addon Name: MongoDB Query Executor
Jarvis Link: https://jarvis.testsigma.com/ui/tenants/2817/addons
Jira : https://testsigma.atlassian.net/browse/CUS-11035
Migrated the classes to other applications

Summary by CodeRabbit

Release Notes

  • New Features
    • Added MongoDB integration capabilities across multiple application types (Android, iOS, Web, Mobile Web, REST API, Windows).
    • Added actions to retrieve databases, collections, and document values from MongoDB.
    • Added MongoDB query executor supporting find, insert, update, delete, and aggregate operations.
    • Added ability to store MongoDB query results in runtime variables for use in subsequent steps.

@coderabbitai

coderabbitai Bot commented Mar 3, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Introduces two complete Maven modules: mongodb_nlps (MongoDB operations for collections and databases) and mongodb_query_executor (query execution with CRUD and index operations). Adds ~60 new action classes across Android, iOS, mobile web, web, REST API, and Windows platforms, plus supporting operations and factory classes.

Changes

Cohort / File(s) Summary
Build Configuration
mongodb_nlps/pom.xml, mongodb_query_executor/pom.xml
Maven POM files defining project metadata, Java 11 compilation, dependencies (Testsigma SDK, Lombok, JUnit, TestNG, Selenium, Appium, MongoDB driver), and build plugins (maven-shade-plugin, maven-source-plugin) for both modules.
MongoDB Collection/Database Operations (Android)
mongodb_nlps/src/main/java/com/testsigma/addons/android/MongoDB_GetListofCollection.java, MongoDB_GetListofCollectionsWithConnectionURL.java, MongoDB_GetListofDatabases.java, MongoDB_GetvaluesofCollection.java, MongoDB_GetvaluesofCollectionWithConnectionURL.java
Five Android action classes providing MongoDB operations: retrieve collection/database names, fetch all documents from collections, supporting both direct URI connection strings and connection URLs. All include error handling and HTML-formatted result strings.
MongoDB Collection/Database Operations (iOS)
mongodb_nlps/src/main/java/com/testsigma/addons/ios/MongoDB_GetListofCollection.java, MongoDB_GetListofCollectionsWithConnectionURL.java, MongoDB_GetListofDatabases.java, MongoDB_GetvaluesofCollection.java, MongoDB_GetvaluesofCollectionWithConnectionURL.java
Five iOS action classes mirroring Android implementations for MongoDB collection/database retrieval and document enumeration with consistent error handling patterns.
MongoDB Collection/Database Operations (Mobile Web)
mongodb_nlps/src/main/java/com/testsigma/addons/mobileweb/MongoDB_GetListofCollection.java, MongoDB_GetListofCollectionsWithConnectionURL.java, MongoDB_GetListofDatabases.java, MongoDB_GetvaluesofCollection.java, MongoDB_GetvaluesofCollectionWithConnectionURL.java
Five WebAction-based classes for mobile web platform executing MongoDB collection, database, and document operations with TestData input bindings and consistent result formatting.
MongoDB Collection/Database Operations (Web)
mongodb_nlps/src/main/java/com/testsigma/addons/web/MongoDB_GetListofCollection.java, MongoDB_GetListofCollectionsWithConnectionURL.java, MongoDB_GetListofDatabases.java, MongoDB_GetvaluesofCollection.java, MongoDB_GetvaluesofCollectionWithConnectionURL.java
Five WebAction implementations for web platform providing MongoDB collection/database access with result aggregation into HTML-formatted strings and exception handling.
MongoDB Collection/Database Operations (REST API)
mongodb_nlps/src/main/java/com/testsigma/addons/restapi/MongoDB_GetListofCollection.java, MongoDB_GetListofCollectionsWithConnectionURL.java, MongoDB_GetListofDatabases.java, MongoDB_GetvaluesofCollection.java, MongoDB_GetvaluesofCollectionWithConnectionURL.java
Five RestApiAction classes extending MongoDB operations to REST API platform with consistent test data binding and result formatting patterns.
MongoDB Collection/Database Operations (Windows)
mongodb_nlps/src/main/java/com/testsigma/addons/windows/MongoDB_GetListofCollection.java, MongoDB_GetListofCollectionsWithConnectionURL.java, MongoDB_GetListofDatabases.java, MongoDB_GetvaluesofCollection.java, MongoDB_GetvaluesofCollectionWithConnectionURL.java
Five WindowsAction implementations mirroring other platforms' MongoDB operations with same functional patterns and error handling.
MongoDB Query Execution Core Infrastructure
mongodb_query_executor/src/main/java/com/testsigma/addons/Utils/MongoOperation.java, MongoOperationFactory.java
Interface and factory for dispatching MongoDB operations (Find, Aggregate, Insert, Update, Delete, Index) based on query string pattern matching.
MongoDB Operations (Find, Aggregate, Insert, Update, Delete, Index)
mongodb_query_executor/src/main/java/com/testsigma/addons/Operations/FindOperation.java, AggregationOperation.java, InsertOperation.java, UpdateOperation.java, DeleteOperation.java, IndexOperation.java
Six operation classes implementing MongoOperation interface: parse MongoDB-style query strings (db.collection.operation format), extract parameters, execute operations, format JSON results, and handle exceptions with stack trace capture.
MongoDB Query Executor Actions (Android, iOS, Mobile Web)
mongodb_query_executor/src/main/java/com/testsigma/addons/android/MongoDB_QueryExecutor.java, MongoDB_QueryExecutorAndStoresInaVariable.java, and corresponding iOS/mobile web variants
Six action classes for Android/iOS/mobile web executing arbitrary MongoDB queries via MongoOperationFactory, with optional runtime variable storage for results; reject destructive operations (delete, index creation).
MongoDB Query Executor Actions (Web, REST API, Windows)
mongodb_query_executor/src/main/java/com/testsigma/addons/web/MongoDB_QueryExecutor.java, MongoDB_QueryExecutorAndStoresInaVariable.java, and corresponding REST API/Windows variants
Six action classes for web/REST API/Windows platforms executing MongoDB queries with result extraction and optional storage in runtime variables.
SDK Configuration & Properties
mongodb_nlps/src/main/resources/testsigma-sdk.properties, mongodb_query_executor/src/main/resources/testsigma-sdk.properties
Two property files containing Testsigma SDK API key tokens for module authentication.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Platform as Android/iOS/<br/>Web/etc. Action
    participant SDK as MongoClient
    participant MongoDB as MongoDB<br/>Server
    
    User->>Platform: Invoke Action with TestData
    Platform->>Platform: Parse connection string & query
    Platform->>SDK: Create MongoClient(URI)
    SDK->>MongoDB: Establish Connection
    MongoDB-->>SDK: Connection Established
    Platform->>SDK: Execute Query<br/>(find/aggregate/insert/etc.)
    SDK->>MongoDB: Send Operation
    MongoDB-->>SDK: Return Results/Cursor
    SDK->>Platform: Accumulate Results to StringBuffer
    Platform->>Platform: Format Result String
    Platform->>User: Return Result with Message
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested reviewers

  • Ganesh-Testsigma
  • vigneshtestsigma

Poem

🐰 Hops with glee through MongoDB's halls,
Queries echoing through Testsigma's walls!
Six platforms now, with operations galore,
Collections and databases, forevermore!
Let indexes dance and documents flow,
The addon adventure continues to grow! 🚀

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.34% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat/CUS-11035-Migrated the classes to other applications' describes the main change—migrating MongoDB addon classes across multiple application types (Android, iOS, web, mobile web, REST API, Windows).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/CUS-11035-Migrated-the-classes-to-other-applications

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 8

Note

Due to the large number of review comments, Critical severity comments were prioritized as inline comments.

🟡 Minor comments (12)
mongodb_nlps/src/main/java/com/testsigma/addons/mobileweb/MongoDB_GetvaluesofCollectionWithConnectionURL.java-53-53 (1)

53-53: ⚠️ Potential issue | 🟡 Minor

Potential credential exposure in logs.

connection (from MongoDB_ConnectionURL) may contain credentials. Logging it alongside fetched values could leak sensitive information. Consider logging only the database and collection names, not the full connection string or raw document contents.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/mobileweb/MongoDB_GetvaluesofCollectionWithConnectionURL.java`
at line 53, The current logger.info call in
MongoDB_GetvaluesofCollectionWithConnectionURL (logger.info("Successfully
fetched the values from collection: " + sb.toString())) may print the full
connection string and raw documents; update this to avoid credential and data
exposure by removing the raw connection and document payload from logs—use
MongoDB_ConnectionURL only to extract and log safe metadata (database name and
collection name) and optionally a document count or masked summary instead of
sb.toString(); locate usages of sb and the logger.info call in class
MongoDB_GetvaluesofCollectionWithConnectionURL and replace the message with one
that references only the database/collection names and non-sensitive metrics.
mongodb_nlps/src/main/java/com/testsigma/addons/mobileweb/MongoDB_GetListofCollection.java-44-47 (1)

44-47: ⚠️ Potential issue | 🟡 Minor

Collection names concatenated without separators.

Collection names are appended directly without delimiters, producing unreadable output like <br>collection1collection2collection3. Add a separator between names.

🐛 Proposed fix
 			sb.append("<br>");
 			for (String collections : colls) {
-				sb.append(collections);
+				sb.append(collections).append(", ");
 			}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/mobileweb/MongoDB_GetListofCollection.java`
around lines 44 - 47, In MongoDB_GetListofCollection, the for-loop that iterates
over colls appends each collections string directly to sb
(sb.append(collections)), producing concatenated names; modify the loop to
append a delimiter between names (for example,
sb.append(collections).append("<br>") or sb.append(collections).append(", ")) so
collection names are separated and readable, ensuring you update only the loop
using the colls variable and sb.append calls.
mongodb_query_executor/pom.xml-17-17 (1)

17-17: ⚠️ Potential issue | 🟡 Minor

Use a stable GA release of JUnit Jupiter instead of the milestone version.

Line 17 uses 5.8.0-M1, a milestone pre-release from February 2021. Stable GA releases are available (5.11.4 as of December 2024, or 5.14.1/6.0.1 from October 2025). Using a stable release provides better predictability, wider ecosystem compatibility, and vendor support.

Also applies to: 37-41

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mongodb_query_executor/pom.xml` at line 17, The pom.xml uses a milestone
pre-release value for the junit.jupiter.version property
(<junit.jupiter.version>5.8.0-M1</junit.jupiter.version>); replace it with a
stable GA version (for example 5.11.4 or a more current GA) and update any other
occurrences of the same property (noted around the block at lines 37-41) so the
project consistently references the stable JUnit Jupiter release.
mongodb_nlps/src/main/java/com/testsigma/addons/web/MongoDB_GetvaluesofCollection.java-39-46 (1)

39-46: ⚠️ Potential issue | 🟡 Minor

Validate required input bindings before dereferencing.

getValue().toString() at Line 39, Line 44, and Line 46 can throw NPE for missing test data and hide the real configuration issue.

✅ Proposed validation
       try{
+          if (testData1 == null || testData1.getValue() == null
+              || testData2 == null || testData2.getValue() == null
+              || testData3 == null || testData3.getValue() == null) {
+            throw new IllegalArgumentException("DBname, MongoDB_Connection, and CollectionName are required.");
+          }
+
           String connection = testData2.getValue().toString();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/web/MongoDB_GetvaluesofCollection.java`
around lines 39 - 46, The code dereferences testData2.getValue().toString(),
testData1.getValue().toString(), and testData3.getValue().toString() without
null checks; add validation in MongoDB_GetvaluesofCollection before using these
values: verify testData1, testData2, testData3 and their getValue() results are
non-null and non-empty, and if any are missing throw a clear exception or call
the task's failure path with an explanatory message (e.g., "missing connection
string" / "missing database name" / "missing collection name") instead of
proceeding to create MongoClientURI, new MongoClient, db.getDB(...) or
db.getCollection(...). Ensure the logic references the same variables
(testData1, testData2, testData3) so callers see a helpful error rather than an
NPE.
mongodb_nlps/src/main/java/com/testsigma/addons/android/MongoDB_GetListofCollection.java-45-47 (1)

45-47: ⚠️ Potential issue | 🟡 Minor

Collection names are concatenated without separators.

The loop appends names but no delimiter/newline, so results become a single merged token stream.

Proposed fix
 for (String collections : colls) {
   sb.append(collections);
+  sb.append("<br>");
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/android/MongoDB_GetListofCollection.java`
around lines 45 - 47, The code in MongoDB_GetListofCollection is appending
collection names into the StringBuilder sb without any separator (loop over
colls), producing a merged token stream; fix it by inserting a delimiter between
names — either use String.join(",", colls) or update the loop that iterates over
colls to append a separator (e.g., sb.append(collections).append(",") or
append("\n")) and trim the trailing separator before returning; locate the sb
and colls usage in the MongoDB_GetListofCollection class/method and apply the
change.
mongodb_query_executor/src/main/java/com/testsigma/addons/web/MongoDB_QueryExecutorAndStoresInaVariable.java-67-75 (1)

67-75: ⚠️ Potential issue | 🟡 Minor

Fragile JSON extraction may produce incorrect results.

The substring extraction using indexOf("[{") and lastIndexOf("}]") assumes the result always contains a JSON array with objects. This will fail or produce incorrect results for:

  • Empty arrays []
  • Arrays with primitives [1, 2, 3]
  • Single objects {...}
  • Results where [{ or }] appear in string values
💡 Consider using a JSON parser or more robust extraction
-                // Extract only the JSON array part from the result
-                String resultString = sb.toString();
-                int startIndex = resultString.indexOf("[{");
-                int endIndex = resultString.lastIndexOf("}]") + 2;
-
-                // Extract meaningful JSON result
-                if (startIndex >= 0 && endIndex > startIndex) {
-                    resultString = resultString.substring(startIndex, endIndex);
-                }
+                String resultString = sb.toString().trim();

If structured JSON extraction is needed, consider using a JSON library to parse and validate the result.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_query_executor/src/main/java/com/testsigma/addons/web/MongoDB_QueryExecutorAndStoresInaVariable.java`
around lines 67 - 75, The current fragile extraction in
MongoDB_QueryExecutorAndStoresInaVariable (the block that creates resultString
from sb and uses indexOf("[{")/lastIndexOf("}]")) should be replaced with robust
JSON parsing: use a JSON library (e.g., Jackson ObjectMapper.readTree or Gson
JsonParser) to parse sb.toString() into a JsonNode/JsonElement, detect whether
the parsed value is an array, object, or primitive, normalize the output (e.g.,
if object/primitive, wrap into an array or serialize appropriately), handle
empty arrays explicitly, and return the validated JSON string instead of relying
on substring heuristics; update the code paths that reference resultString
accordingly.
mongodb_query_executor/src/main/java/com/testsigma/addons/Operations/InsertOperation.java-93-97 (1)

93-97: ⚠️ Potential issue | 🟡 Minor

insertOne payload extraction breaks when options are present.

Line 93-96 slices from first { to last }, so queries like insertOne(doc, options) produce invalid JSON extraction and fail parsing.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_query_executor/src/main/java/com/testsigma/addons/Operations/InsertOperation.java`
around lines 93 - 97, The current extraction in InsertOperation (using
queryInput.substring from queryInput.indexOf("{") to lastIndexOf("}") into
jsonObject and then Document.parse) fails when insertOne is called with options
(e.g., insertOne(doc, options);) because it grabs too much text; update the
parsing logic in the InsertOperation class to locate the first `{` and the
matching closing `}` for that object (not the last `}` in the string) — e.g.,
walk characters from queryInput.indexOf("{") counting braces to find the
matching end, extract that slice into jsonObject, then pass it to
Document.parse; ensure this handles nested braces and trims whitespace before
parsing.
mongodb_query_executor/src/main/java/com/testsigma/addons/restapi/MongoDB_QueryExecutorAndStoresInaVariable.java-56-57 (1)

56-57: ⚠️ Potential issue | 🟡 Minor

Supported-operation messaging is inconsistent.

Lines 56-57 reject createIndex/dropIndex/getIndexes, while Line 90 says 'index' queries are supported. Align validation and error text to avoid contradictory behavior.

Also applies to: 90-90

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_query_executor/src/main/java/com/testsigma/addons/restapi/MongoDB_QueryExecutorAndStoresInaVariable.java`
around lines 56 - 57, The validation in
MongoDB_QueryExecutorAndStoresInaVariable is inconsistent: the if that checks
queryInput and calls setErrorMessage rejects createIndex/dropIndex/getIndexes
while later logic (around the 'index' handling) advertises index queries are
supported; update the validation to either allow index-related operations or
change the messaging to consistently disallow them. Specifically, modify the
queryInput check (the condition referencing "deleteOne", "deleteMany",
"createIndex", "dropIndex", "getIndexes") to only reject the operations you
truly want blocked (e.g., keep deleteOne/deleteMany) or remove the index strings
so index paths are allowed, and adjust the setErrorMessage text so it matches
the behavior used by the index-handling code elsewhere in the
MongoDB_QueryExecutorAndStoresInaVariable class.
mongodb_query_executor/src/main/java/com/testsigma/addons/android/MongoDB_QueryExecutorAndStoresInaVariable.java-56-57 (1)

56-57: ⚠️ Potential issue | 🟡 Minor

Operation support checks conflict with error messaging.

createIndex/dropIndex/getIndexes are blocked in Lines 56-57, but Line 90 states index queries are supported.

Also applies to: 90-90

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_query_executor/src/main/java/com/testsigma/addons/android/MongoDB_QueryExecutorAndStoresInaVariable.java`
around lines 56 - 57, The current check in
MongoDB_QueryExecutorAndStoresInaVariable.java that insallows operations if
queryInput contains "deleteOne" || "deleteMany" || "createIndex" || "dropIndex"
|| "getIndexes" conflicts with later logic that claims index queries are
supported; update the validation inside the method that checks queryInput (the
block setting setErrorMessage("Operation not supported.")) to remove
"createIndex", "dropIndex", and "getIndexes" from the blocked list so
index-related operations are allowed, or alternatively change the later support
text to match the blocked operations — ensure you modify the same method where
queryInput is evaluated and the call to setErrorMessage(...) is made so behavior
and messaging are consistent.
mongodb_query_executor/src/main/java/com/testsigma/addons/mobileweb/MongoDB_QueryExecutorAndStoresInaVariable.java-56-57 (1)

56-57: ⚠️ Potential issue | 🟡 Minor

Unsupported-operation message contradicts runtime checks.

Line 56 blocks index-related operations, but Line 90 tells users 'index' queries are supported.

🔧 Proposed fix
-                setErrorMessage("Unsupported query operation. Only 'find', 'insert', 'update', 'aggregate' and 'index' queries are supported. Query: " + queryInput);
+                setErrorMessage("Unsupported query operation. Only 'find', 'insert', 'update', and 'aggregate' queries are supported in this action. Query: " + queryInput);

Also applies to: 90-91

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_query_executor/src/main/java/com/testsigma/addons/mobileweb/MongoDB_QueryExecutorAndStoresInaVariable.java`
around lines 56 - 57, The current guard in
MongoDB_QueryExecutorAndStoresInaVariable that checks queryInput and calls
setErrorMessage("Operation not supported.") incorrectly blocks index-related
operations (createIndex, dropIndex, getIndexes) while later code (around the
'index' handling at lines ~90-91) claims index queries are supported; to fix,
update the conditional that examines queryInput so it only rejects truly
unsupported operations (e.g., keep deleteOne/deleteMany) and remove
createIndex/dropIndex/getIndexes (and any 'index' substring) from that
blacklist, or alternatively adjust the condition to explicitly allow
index-related queries before setting setErrorMessage; ensure you modify the
queryInput check and the setErrorMessage invocation so index operations routed
to the index-handling logic (refer to queryInput, setErrorMessage, and the index
handling block).
mongodb_query_executor/src/main/java/com/testsigma/addons/ios/MongoDB_QueryExecutorAndStoresInaVariable.java-56-57 (1)

56-57: ⚠️ Potential issue | 🟡 Minor

Keep supported-operation messaging consistent with actual checks.

Line 56 rejects index operations, but Line 90 states index is supported.

Also applies to: 90-91

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_query_executor/src/main/java/com/testsigma/addons/ios/MongoDB_QueryExecutorAndStoresInaVariable.java`
around lines 56 - 57, The unsupported-operation check on queryInput currently
treats "createIndex", "dropIndex", and "getIndexes" as unsupported by calling
setErrorMessage("Operation not supported."), but elsewhere the code reports that
index operations are supported; make these messages consistent by either
removing "createIndex"/"dropIndex"/"getIndexes" from the unsupported check
(queryInput.contains(...) branch) if index operations are intended to be
supported, or by changing the later success/message branch that mentions index
support to indicate they are unsupported; update the condition around queryInput
and the corresponding setErrorMessage/setSuccess message so they match,
referencing the queryInput variable and the setErrorMessage call and the code
path that emits the index-support message.
mongodb_query_executor/src/main/java/com/testsigma/addons/Operations/FindOperation.java-30-30 (1)

30-30: ⚠️ Potential issue | 🟡 Minor

Collection-name regex is too restrictive.

Line 30 uses (\w+), which rejects common names like audit-log. This can fail valid queries before execution.

🔧 Proposed fix
-            Pattern findPattern = Pattern.compile("^db\\.(\\w+)\\.find\\((.*)\\)(\\s*\\.\\s*\\w+\\([^)]*\\))*$");
+            Pattern findPattern = Pattern.compile("^db\\.([A-Za-z0-9_\\-]+)\\.find\\((.*)\\)(\\s*\\.\\s*\\w+\\([^)]*\\))*$");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_query_executor/src/main/java/com/testsigma/addons/Operations/FindOperation.java`
at line 30, The current regex in FindOperation that builds findPattern uses
(\w+) for the collection name which rejects valid collection names like
audit-log; update the pattern to allow hyphens and other common characters (e.g.
replace (\w+) with ([A-Za-z0-9_-]+) or ([\w-]+)) so the collection-name capture
group accepts names with hyphens while preserving the rest of the pattern and
group order; modify the Pattern.compile call that assigns findPattern
accordingly.
🧹 Nitpick comments (29)
mongodb_nlps/src/main/java/com/testsigma/addons/ios/MongoDB_GetListofDatabases.java (1)

6-6: Remove unused import.

AndroidAction is imported but never used; the class extends IOSAction.

🧹 Proposed fix
-import com.testsigma.sdk.AndroidAction;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/ios/MongoDB_GetListofDatabases.java`
at line 6, Remove the unused import of com.testsigma.sdk.AndroidAction from
MongoDB_GetListofDatabases.java since the class extends IOSAction and never
references AndroidAction; locate the import statement and delete it to avoid the
unused-import warning.
mongodb_nlps/src/main/java/com/testsigma/addons/mobileweb/MongoDB_GetvaluesofCollectionWithConnectionURL.java (2)

4-4: Remove unused import.

AndroidAction is imported but never used. The class extends WebAction.

Proposed fix
-import com.testsigma.sdk.AndroidAction;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/mobileweb/MongoDB_GetvaluesofCollectionWithConnectionURL.java`
at line 4, Remove the unused import of AndroidAction from the top of
MongoDB_GetvaluesofCollectionWithConnectionURL.java; since the class extends
WebAction and never references AndroidAction, delete the line "import
com.testsigma.sdk.AndroidAction;" to clean up imports and avoid warnings.

41-46: Migrate from deprecated MongoDB Java driver APIs.

MongoClient.getDB(), DB, DBCollection, and DBCursor are deprecated legacy APIs. Modern code should use MongoClient.getDatabase(String) to obtain MongoDatabase, then call getCollection(String) to obtain MongoCollection<Document>. Additionally, replace raw type Iterator with a properly parameterized type for type safety.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/mobileweb/MongoDB_GetvaluesofCollectionWithConnectionURL.java`
around lines 41 - 46, Replace deprecated legacy driver usage in
MongoDB_GetvaluesofCollectionWithConnectionURL: instead of
mongoClient.getDB(database) and DB/DBCollection/DBCursor types, call
mongoClient.getDatabase(database) to get a com.mongodb.client.MongoDatabase,
then use getCollection(testData3.getValue().toString()) to obtain a
com.mongodb.client.MongoCollection<Document>; use FindIterable<Document> or
collection.find() and a MongoCursor<Document> or Iterator<Document> (or a
for-each over Iterable<Document>) instead of raw Iterator to iterate documents,
and update any variables/methods that reference DB, DBCollection, DBCursor, or
raw Iterator to the new types for type safety.
mongodb_nlps/src/main/java/com/testsigma/addons/mobileweb/MongoDB_GetListofCollection.java (3)

6-6: Unused import: AndroidAction.

This import is not used and should be removed.

🧹 Proposed fix
-import com.testsigma.sdk.AndroidAction;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/mobileweb/MongoDB_GetListofCollection.java`
at line 6, Remove the unused import com.testsigma.sdk.AndroidAction from the
MongoDB_GetListofCollection.java file; locate the import statement at the top of
the class (in the imports block for the MongoDB_GetListofCollection class) and
delete that specific import line so only required imports remain.

28-28: Field visibility and type: prefer private StringBuilder.

The sb field should be private to follow encapsulation. Also, StringBuilder is preferred over StringBuffer in single-threaded contexts (no synchronization overhead).

♻️ Proposed fix
-	StringBuffer sb = new StringBuffer();
+	private StringBuilder sb = new StringBuilder();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/mobileweb/MongoDB_GetListofCollection.java`
at line 28, Change the mutable field declaration StringBuffer sb to a private
StringBuilder to enforce encapsulation and avoid unnecessary synchronization; in
class MongoDB_GetListofCollection replace the package-visible "sb" field with
"private StringBuilder sb" and update any usages in methods (e.g., where
sb.append(), sb.toString(), sb.setLength()) to work with StringBuilder (no other
API changes needed) and ensure any initialization uses new StringBuilder()
rather than new StringBuffer().

3-5: Migrate away from deprecated MongoDB Java driver legacy API.

DB, MongoClient(MongoClientURI), getDB(), and getCollectionNames() are deprecated in MongoDB Java driver 3.x and removed entirely in 4.x. Use the current sync API instead: com.mongodb.client.MongoClients.create(), MongoDatabase, and listCollectionNames(). This ensures compatibility with modern driver versions and access to current features and security updates.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/mobileweb/MongoDB_GetListofCollection.java`
around lines 3 - 5, The code uses deprecated legacy MongoDB classes and methods
(DB, MongoClient(MongoClientURI), getDB(), getCollectionNames())—replace them
with the modern sync API: create a client via
com.mongodb.client.MongoClients.create(), obtain a MongoDatabase (instead of DB)
and call database.listCollectionNames() (instead of getCollectionNames());
update imports (remove com.mongodb.DB, com.mongodb.MongoClient,
com.mongodb.MongoClientURI and add com.mongodb.client.MongoClients,
com.mongodb.client.MongoDatabase, com.mongodb.client.MongoClient) and adjust any
code in class MongoDB_GetListofCollection that references MongoClient,
MongoClientURI, getDB(), or getCollectionNames() to the new types and method
names.
mongodb_nlps/src/main/java/com/testsigma/addons/android/MongoDB_GetvaluesofCollectionWithConnectionURL.java (2)

7-7: Unused import: WebAction.

WebAction is imported but not used. This class extends AndroidAction.

🧹 Proposed fix
 import com.testsigma.sdk.AndroidAction;
 import com.testsigma.sdk.ApplicationType;
 import com.testsigma.sdk.Result;
-import com.testsigma.sdk.WebAction;
 import com.testsigma.sdk.annotation.Action;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/android/MongoDB_GetvaluesofCollectionWithConnectionURL.java`
at line 7, The import com.testsigma.sdk.WebAction is unused in the
MongoDB_GetvaluesofCollectionWithConnectionURL class (which extends
AndroidAction); remove that import to clean up the unused dependency. Locate the
import statement for WebAction at the top of
MongoDB_GetvaluesofCollectionWithConnectionURL.java and delete it so the file
only imports classes actually referenced by the class.

28-28: Move StringBuffer to local scope within execute().

Same issue as in the web variant—declaring sb as an instance field causes data accumulation across multiple calls.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/android/MongoDB_GetvaluesofCollectionWithConnectionURL.java`
at line 28, The StringBuffer field 'sb' in class
MongoDB_GetvaluesofCollectionWithConnectionURL should be moved from an instance
field into a local variable inside the execute() method to avoid cross-call
accumulation; remove the class-level declaration "StringBuffer sb" and instead
declare and initialize a new StringBuffer (or preferably StringBuilder) at the
start of the execute() method where 'sb' is used (refer to execute()) so each
invocation gets a fresh buffer.
mongodb_nlps/src/main/java/com/testsigma/addons/ios/MongoDB_GetvaluesofCollectionWithConnectionURL.java (3)

28-28: Move StringBuffer to local scope within execute().

Same issue as in other platform variants—declaring sb as an instance field causes data accumulation across multiple calls.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/ios/MongoDB_GetvaluesofCollectionWithConnectionURL.java`
at line 28, The instance field StringBuffer sb in class
MongoDB_GetvaluesofCollectionWithConnectionURL should be moved into the
execute() method to prevent data accumulation across calls; remove the
class-level declaration of sb and instead declare and initialize a new
StringBuffer (or StringBuilder) at the start of execute(), then update all
references in that method to use the local sb variable (e.g., inside execute()
where sb.append(...) is used) so each invocation starts with a fresh buffer.

4-4: Unused import: AndroidAction.

AndroidAction is imported but not used. This class extends IOSAction.

🧹 Proposed fix
 import com.mongodb.*;
-import com.testsigma.sdk.AndroidAction;
 import com.testsigma.sdk.ApplicationType;
 import com.testsigma.sdk.IOSAction;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/ios/MongoDB_GetvaluesofCollectionWithConnectionURL.java`
at line 4, Remove the unused import AndroidAction from the top of the
MongoDB_GetvaluesofCollectionWithConnectionURL class; the class extends
IOSAction so AndroidAction is unnecessary—open the class
MongoDB_GetvaluesofCollectionWithConnectionURL, delete the line importing
com.testsigma.sdk.AndroidAction, and ensure imports are organized/compiled
without that unused symbol.

1-63: Consider extracting shared MongoDB logic to a common utility class.

All three platform variants (web, android, ios) contain identical MongoDB connection and query logic. This duplication increases maintenance burden. Consider extracting the core MongoDB operations into a shared utility class that all platform-specific actions can delegate to.

Example structure:

// In a shared utility package
public class MongoDbHelper {
    public static String fetchCollectionValues(String connectionUrl, String database, String collectionName) {
        // Shared MongoDB logic here
    }
}

Each platform action would then simply call this helper and handle success/failure messaging.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/ios/MongoDB_GetvaluesofCollectionWithConnectionURL.java`
around lines 1 - 63, This class duplicates MongoDB connection/query logic shared
across platforms; extract that logic into a new shared utility (e.g., class
MongoDbHelper with a static method fetchCollectionValues(String connectionUrl,
String database, String collectionName) that: creates
MongoClientURI/MongoClient, gets DB and collection, iterates the DBCursor to
build and return the result string, ensures the client is closed, and throws or
returns errors as needed), then update
MongoDB_GetvaluesofCollectionWithConnectionURL.execute() to call
MongoDbHelper.fetchCollectionValues(testData2.getValue().toString(),
testData1.getValue().toString(), testData3.getValue().toString()), set the
success/error messages from the helper’s result or exception, and remove the
duplicated connection/iteration code (also apply the same refactor to the
web/android variants).
mongodb_nlps/src/main/java/com/testsigma/addons/web/MongoDB_GetvaluesofCollectionWithConnectionURL.java (3)

3-9: Remove unused imports.

The following imports are not used in this class: MongoCredential, ServerAddress, and Arrays.

🧹 Proposed fix
 import com.mongodb.DB;
 import com.mongodb.DBCollection;
 import com.mongodb.DBCursor;
 import com.mongodb.MongoClient;
 import com.mongodb.MongoClientURI;
-import com.mongodb.MongoCredential;
-import com.mongodb.ServerAddress;
 import com.testsigma.sdk.ApplicationType;
 import com.testsigma.sdk.Result;
 import com.testsigma.sdk.WebAction;
 import com.testsigma.sdk.annotation.Action;
 import com.testsigma.sdk.annotation.TestData;
 import lombok.Data;

-import java.util.Arrays;
 import java.util.Iterator;

Also applies to: 17-18

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/web/MongoDB_GetvaluesofCollectionWithConnectionURL.java`
around lines 3 - 9, The class MongoDB_GetvaluesofCollectionWithConnectionURL
contains unused imports (MongoCredential, ServerAddress, and Arrays); remove
these import statements and any corresponding unused references so only actually
used imports (DB, DBCollection, DBCursor, MongoClient, MongoClientURI) remain,
and recompile to ensure no remaining references to MongoCredential,
ServerAddress, or Arrays exist in the class.

35-35: Move StringBuffer to local scope within execute().

Declaring sb as an instance field means it will accumulate data across multiple invocations of execute() on the same instance (if that ever occurs), leading to incorrect results. Declare it locally inside the method.

♻️ Proposed fix
 	`@TestData`(reference = "CollectionName")
 	private com.testsigma.sdk.TestData testData3;
-	StringBuffer sb = new StringBuffer();

 	`@Override`
 	public com.testsigma.sdk.Result execute() throws NoSuchElementException {
 		Result result = Result.SUCCESS;
 		logger.info("Initiating execution");
+		StringBuilder sb = new StringBuilder();
 		try{
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/web/MongoDB_GetvaluesofCollectionWithConnectionURL.java`
at line 35, The StringBuffer sb is declared as a class-level field in
MongoDB_GetvaluesofCollectionWithConnectionURL which can cause data to
accumulate across multiple execute() calls; remove the instance field
declaration of sb and instead declare and initialize a new local StringBuffer
(or StringBuilder) at the start of the execute() method so each invocation gets
a fresh buffer (update any references in execute() to use this local variable).

48-53: Migrate from deprecated MongoDB Java driver legacy API.

MongoClient.getDB(), DB, DBCollection, and DBCursor are deprecated legacy APIs. Replace with the current driver API:

  • getDB(database) → getDatabase(database) (returns MongoDatabase)
  • db.getCollection(name) → db.getCollection(name, Document.class) (returns MongoCollection<Document>)
  • collection.find() → returns FindIterable<Document> with .iterator() returning MongoCursor<Document> instead of Iterator

The modern API provides better maintainability and forward compatibility.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/web/MongoDB_GetvaluesofCollectionWithConnectionURL.java`
around lines 48 - 53, The code uses deprecated legacy MongoDB types and methods
(MongoClient.getDB, DB, DBCollection, DBCursor); replace them with the modern
driver API by changing mongoClient.getDB(database) to
mongoClient.getDatabase(database) and type DB to
com.mongodb.client.MongoDatabase (e.g., MongoDatabase db), change
db.getCollection(testData3.getValue().toString()) to
db.getCollection(testData3.getValue().toString(), org.bson.Document.class) and
use com.mongodb.client.MongoCollection<Document> for collection, and replace
collection.find() / DBCursor/Iterator usage with collection.find() returning a
FindIterable<Document> and iterate using
com.mongodb.client.MongoCursor<Document> (or foreach on the iterable); update
variable types and imports accordingly in the method containing these calls.
mongodb_query_executor/pom.xml (1)

42-46: Move TestNG to test scope.

Line 42-46 currently adds TestNG as a runtime/compile dependency. For this addon module, this should generally be test-only to avoid unnecessary classes in the published JAR.

Suggested 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 `@mongodb_query_executor/pom.xml` around lines 42 - 46, The TestNG dependency
org.testng:testng:6.14.3 is currently declared without a scope and is being
included in the module's published artifact; change the dependency declaration
to be test-only by adding <scope>test</scope> inside the org.testng:testng
dependency block so TestNG is used only for tests and not packaged with the
addon.
mongodb_nlps/src/main/java/com/testsigma/addons/web/MongoDB_GetvaluesofCollection.java (1)

32-32: Avoid retaining collection output in a class field.

sb at Line 32 is shared mutable state and is never reset; if this action instance is reused, results from previous executions can leak into later runs. Build the buffer locally inside execute().

♻️ Proposed refactor
- StringBuffer sb = new StringBuffer();
@@
-      sb.append("<br>");
+      StringBuilder sb = new StringBuilder("<br>");
       while (it.hasNext()) {
         sb.append(it.next());
         sb.append("<br>");
       }

Also applies to: 50-54

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/web/MongoDB_GetvaluesofCollection.java`
at line 32, The StringBuffer field sb is shared mutable state; move its
declaration and construction into the execute() method (or any method that runs
per-invocation) so each execution gets a fresh buffer, update all usages that
currently reference the field (e.g., concatenation logic around lines 50-54) to
use the local buffer, and remove the class-level sb field; if you must keep a
field instead, explicitly reset it at the start of execute() with
sb.setLength(0) but preferred fix is to create a local
StringBuilder/StringBuffer inside execute() and return/use that.
mongodb_nlps/src/main/java/com/testsigma/addons/web/MongoDB_GetListofDatabases.java (1)

27-47: Use a method-local builder instead of class field sb.

Keeping sb as instance state can carry stale results between executions if this action object is reused. Make it local in execute().

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/web/MongoDB_GetListofDatabases.java`
around lines 27 - 47, The StringBuffer field sb on the class causes
stale/cross-execution state; remove the class-level sb and declare a
method-local builder inside execute() (e.g., StringBuilder sb = new
StringBuilder()) in MongoDB_GetListofDatabases.execute(), update all uses of sb
in that method (appends, setSuccessMessage, logger.info) to use the local
variable, and delete the class field declaration to ensure each execution starts
with a fresh buffer.
mongodb_nlps/src/main/java/com/testsigma/addons/restapi/MongoDB_GetListofCollectionsWithConnectionURL.java (1)

17-42: Migrate from deprecated DB API calls.

getDB(...).getCollectionNames() (Line 41) is legacy API and currently hidden with deprecation suppression. Prefer MongoDatabase#listCollectionNames() for forward compatibility.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/restapi/MongoDB_GetListofCollectionsWithConnectionURL.java`
around lines 17 - 42, The code uses the deprecated DB API
(MongoClientURI/MongoClient.getDB(...).getCollectionNames()); in execute() of
MongoDB_GetListofCollectionsWithConnectionURL replace that legacy usage with the
modern driver: create a com.mongodb.client.MongoClient via
MongoClients.create(connection), call
mongoClient.getDatabase(database).listCollectionNames() (iterate/collect into a
Set<String> named colls), and close the client afterward; update imports to use
com.mongodb.client.MongoClient, com.mongodb.client.MongoClients and
com.mongodb.client.MongoDatabase and remove MongoClientURI usage.
mongodb_nlps/src/main/java/com/testsigma/addons/windows/MongoDB_GetListofCollectionsWithConnectionURL.java (1)

17-42: Avoid deprecated getDB(...).getCollectionNames() path.

This flow is already guarded by @SuppressWarnings("deprecation"); please migrate to MongoDatabase#listCollectionNames() to reduce driver-upgrade risk.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/windows/MongoDB_GetListofCollectionsWithConnectionURL.java`
around lines 17 - 42, The current execute() in
MongoDB_GetListofCollectionsWithConnectionURL uses the deprecated
mongoClient.getDB(database).getCollectionNames(); replace it with the supported
API: obtain a MongoDatabase via mongoClient.getDatabase(database) and call
listCollectionNames() (e.g., collect into a Set or iterate the MongoIterable) so
the rest of the logic that uses the collection names remains unchanged; ensure
you import or use appropriate collection conversion (e.g., into a Set<String>)
and still handle/close the MongoClient created from MongoClientURI accordingly.
mongodb_nlps/src/main/java/com/testsigma/addons/ios/MongoDB_GetListofCollection.java (1)

3-14: Remove unused import AndroidAction.

The import com.testsigma.sdk.AndroidAction at line 6 is not used in this iOS action class.

🧹 Remove unused import
 import com.mongodb.DB;
 import com.mongodb.MongoClient;
 import com.mongodb.MongoClientURI;
-import com.testsigma.sdk.AndroidAction;
 import com.testsigma.sdk.ApplicationType;
 import com.testsigma.sdk.IOSAction;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/ios/MongoDB_GetListofCollection.java`
around lines 3 - 14, Remove the unused import com.testsigma.sdk.AndroidAction
from the MongoDB_GetListofCollection class; locate the import statement at the
top of the file (the line importing AndroidAction) and delete it so only the
necessary imports (e.g., IOSAction, Result, Action, TestData, etc.) remain, then
recompile to ensure no references to AndroidAction exist elsewhere in this
class.
mongodb_nlps/src/main/java/com/testsigma/addons/web/MongoDB_GetListofCollectionsWithConnectionURL.java (1)

3-14: Remove unused imports.

MongoCredential, ServerAddress, and Arrays are imported but never used.

🧹 Remove unused imports
 import com.mongodb.MongoClient;
 import com.mongodb.MongoClientURI;
-import com.mongodb.MongoCredential;
-import com.mongodb.ServerAddress;
 import com.testsigma.sdk.ApplicationType;
 import com.testsigma.sdk.Result;
 import com.testsigma.sdk.WebAction;
 import com.testsigma.sdk.annotation.Action;
 import com.testsigma.sdk.annotation.TestData;
 import lombok.Data;
-import java.util.Arrays;
 import java.util.Set;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/web/MongoDB_GetListofCollectionsWithConnectionURL.java`
around lines 3 - 14, The file MongoDB_GetListofCollectionsWithConnectionURL
contains unused imports (MongoCredential, ServerAddress, and Arrays); remove
these three import statements from the top of the file so only the actually used
imports (e.g., MongoClient, MongoClientURI, Set, testsigma/sdk imports,
lombok.Data) remain, ensuring there are no unused-import compiler warnings or
clutter in the class.
mongodb_nlps/src/main/java/com/testsigma/addons/android/MongoDB_GetListofCollectionsWithConnectionURL.java (1)

3-13: Remove unused import WebAction.

The import com.testsigma.sdk.WebAction at line 8 is not used.

🧹 Remove unused import
 import com.mongodb.MongoClient;
 import com.mongodb.MongoClientURI;
 import com.testsigma.sdk.AndroidAction;
 import com.testsigma.sdk.ApplicationType;
 import com.testsigma.sdk.Result;
-import com.testsigma.sdk.WebAction;
 import com.testsigma.sdk.annotation.Action;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/android/MongoDB_GetListofCollectionsWithConnectionURL.java`
around lines 3 - 13, Remove the unused import com.testsigma.sdk.WebAction from
the imports at the top of MongoDB_GetListofCollectionsWithConnectionURL.java;
locate the import statement (reference symbol: WebAction) and delete it, then
run a quick compile or IDE auto-import cleanup to ensure there are no remaining
references or unused imports left in the class.
mongodb_nlps/src/main/java/com/testsigma/addons/android/MongoDB_GetListofDatabases.java (1)

6-14: Remove unused import WebAction.

The import com.testsigma.sdk.WebAction at line 9 is not used since this class extends AndroidAction.

🧹 Remove unused import
 import com.testsigma.sdk.AndroidAction;
 import com.testsigma.sdk.ApplicationType;
 import com.testsigma.sdk.Result;
-import com.testsigma.sdk.WebAction;
 import com.testsigma.sdk.annotation.Action;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/android/MongoDB_GetListofDatabases.java`
around lines 6 - 14, Remove the unused import com.testsigma.sdk.WebAction from
the imports in MongoDB_GetListofDatabases.java; locate the import block (which
also contains AndroidAction, ApplicationType, Result, Action, TestData,
lombok.Data, ExceptionUtils, NoSuchElementException) and delete only the
WebAction line so the class that extends AndroidAction no longer has an unused
import.
mongodb_nlps/src/main/java/com/testsigma/addons/restapi/MongoDB_GetListofCollection.java (1)

3-14: Remove unused import AndroidAction.

The import com.testsigma.sdk.AndroidAction at line 6 is not used in this REST API action class.

🧹 Remove unused import
 import com.mongodb.DB;
 import com.mongodb.MongoClient;
 import com.mongodb.MongoClientURI;
-import com.testsigma.sdk.AndroidAction;
 import com.testsigma.sdk.ApplicationType;
 import com.testsigma.sdk.RestApiAction;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/restapi/MongoDB_GetListofCollection.java`
around lines 3 - 14, Remove the unused import com.testsigma.sdk.AndroidAction
from the top of the file; locate the import statement for AndroidAction in the
imports block of the MongoDB_GetListofCollection class and delete it so only
used imports (e.g., RestApiAction, Result, TestData, etc.) remain, then
recompile to ensure no references to AndroidAction exist elsewhere in the class.
mongodb_nlps/pom.xml (2)

42-46: TestNG dependency is missing <scope>test</scope>.

The TestNG dependency will be included in the shaded JAR unnecessarily. It should be scoped to test like junit-jupiter-api.

🔧 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 `@mongodb_nlps/pom.xml` around lines 42 - 46, The TestNG dependency block
(groupId org.testng, artifactId testng, version 6.14.3) should be marked as
test-scoped to prevent it being included in the shaded JAR; update the
dependency for artifactId "testng" to include a <scope>test</scope> element
(matching how junit-jupiter-api is declared) so TestNG is used only for test
compilation/runtime and not packaged into the production artifact.

59-64: Upgrade to a newer MongoDB Java Driver version or document the rationale for staying on 3.x.

Version 3.12.10 exposes deprecated APIs (MongoClientURI, getDB(), MongoClient) that were removed in driver 4.0+. The current latest stable release is 5.6.4, which uses modern equivalents like ConnectionString, MongoClientSettings, MongoClients.create(), and getDatabase(). Evaluate whether upgrading is feasible, or add a comment documenting why this version is required.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mongodb_nlps/pom.xml` around lines 59 - 64, The pom currently pins the
MongoDB driver to org.mongodb:mongo-java-driver:3.12.10 which relies on
deprecated 3.x APIs; either update the dependency to a current 4.x/5.x artifact
(e.g. replace the old artifact with the modern driver and bump the <version> to
a supported release such as 5.6.4) and then refactor usages of
MongoClientURI/getDB/MongoClient to
ConnectionString/MongoClientSettings/MongoClients.create()/getDatabase(), or if
an upgrade is not feasible add a clear comment in the POM explaining the
rationale for staying on 3.12.10 and link to the migration notes; reference the
dependency block (groupId: org.mongodb, artifactId: mongo-java-driver, version)
when making the change.
mongodb_nlps/src/main/java/com/testsigma/addons/android/MongoDB_GetvaluesofCollection.java (1)

45-48: Use typed iteration instead of raw Iterator.

Lines [45-48] use raw iterator types; prefer DBObject iteration for safer handling and clearer intent.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/android/MongoDB_GetvaluesofCollection.java`
around lines 45 - 48, The loop currently uses a raw Iterator (Iterator it =
iterDoc.iterator()) which is unsafe; change it to a typed iterator over DBObject
(e.g., Iterator<DBObject> it = iterDoc.iterator()) and update the while body to
handle DBObject values explicitly (use DBObject variable from it.next() and
append its toString or specific field to sb) so iteration is type-safe and
clearer; update any imports or generics on iterDoc as needed.
mongodb_nlps/src/main/java/com/testsigma/addons/mobileweb/MongoDB_GetvaluesofCollection.java (1)

45-48: Use typed iteration for collection documents.

Lines [45-48] use raw Iterator; prefer typed document iteration for safer casting and clearer behavior.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/mobileweb/MongoDB_GetvaluesofCollection.java`
around lines 45 - 48, In MongoDB_GetvaluesofCollection.java replace the raw
Iterator usage over iterDoc with a typed iterator or enhanced for-loop using
org.bson.Document (e.g., Iterator<Document> or for (Document doc : iterDoc)) so
you avoid unchecked casts; then append a string representation of the document
(doc.toJson() or doc.toString()) to sb instead of appending a raw Object from
it.next(); update any imports/usages accordingly while keeping the existing sb
and iterDoc variables.
mongodb_query_executor/src/main/java/com/testsigma/addons/Operations/IndexOperation.java (1)

22-27: Normalize operation routing before dispatch.

Line 22-Line 27 use case-sensitive contains(...), which is brittle for mixed-case input and future extensions. Parse the operation token once (case-insensitive) and route from that token.

♻️ Suggested refactor
+import java.util.Locale;
...
-            if (queryInput.contains(".createIndex(")) {
+            String normalized = queryInput.toLowerCase(Locale.ROOT);
+            if (normalized.contains(".createindex(")) {
                 return handleCreateIndex(database, queryInput, sb, logger);
-            } else if (queryInput.contains(".dropIndex(")) {
+            } else if (normalized.contains(".dropindex(")) {
                 return handleDropIndex(database, queryInput, sb, logger);
-            } else if (queryInput.contains(".getIndexes(")) {
+            } else if (normalized.contains(".getindexes(")) {
                 return handleGetIndexes(database, queryInput, sb, logger);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_query_executor/src/main/java/com/testsigma/addons/Operations/IndexOperation.java`
around lines 22 - 27, The current routing in IndexOperation.java uses
case-sensitive queryInput.contains(...) checks which fail for mixed-case inputs;
update the routing to parse a single lowercase operation token from queryInput
(e.g., normalize queryInput.toLowerCase() or extract the operation substring)
and then switch/if on that token to call handleCreateIndex, handleDropIndex, or
handleGetIndexes (preserve existing method signatures:
handleCreateIndex(database, queryInput, sb, logger), handleDropIndex(...),
handleGetIndexes(...)); ensure you only compute the normalized token once and
use it for dispatch so routing is case-insensitive and easier to extend.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 40442d3 and 7dfb093.

📒 Files selected for processing (54)
  • mongodb_nlps/pom.xml
  • mongodb_nlps/src/main/java/com/testsigma/addons/android/MongoDB_GetListofCollection.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/android/MongoDB_GetListofCollectionsWithConnectionURL.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/android/MongoDB_GetListofDatabases.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/android/MongoDB_GetvaluesofCollection.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/android/MongoDB_GetvaluesofCollectionWithConnectionURL.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/ios/MongoDB_GetListofCollection.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/ios/MongoDB_GetListofCollectionsWithConnectionURL.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/ios/MongoDB_GetListofDatabases.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/ios/MongoDB_GetvaluesofCollection.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/ios/MongoDB_GetvaluesofCollectionWithConnectionURL.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/mobileweb/MongoDB_GetListofCollection.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/mobileweb/MongoDB_GetListofCollectionsWithConnectionURL.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/mobileweb/MongoDB_GetListofDatabases.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/mobileweb/MongoDB_GetvaluesofCollection.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/mobileweb/MongoDB_GetvaluesofCollectionWithConnectionURL.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/restapi/MongoDB_GetListofCollection.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/restapi/MongoDB_GetListofCollectionsWithConnectionURL.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/restapi/MongoDB_GetListofDatabases.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/restapi/MongoDB_GetvaluesofCollection.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/restapi/MongoDB_GetvaluesofCollectionWithConnectionURL.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/web/MongoDB_GetListofCollection.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/web/MongoDB_GetListofCollectionsWithConnectionURL.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/web/MongoDB_GetListofDatabases.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/web/MongoDB_GetvaluesofCollection.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/web/MongoDB_GetvaluesofCollectionWithConnectionURL.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/windows/MongoDB_GetListofCollection.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/windows/MongoDB_GetListofCollectionsWithConnectionURL.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/windows/MongoDB_GetListofDatabases.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/windows/MongoDB_GetvaluesofCollection.java
  • mongodb_nlps/src/main/java/com/testsigma/addons/windows/MongoDB_GetvaluesofCollectionWithConnectionURL.java
  • mongodb_nlps/src/main/resources/testsigma-sdk.properties
  • mongodb_query_executor/pom.xml
  • mongodb_query_executor/src/main/java/com/testsigma/addons/Operations/AggregationOperation.java
  • mongodb_query_executor/src/main/java/com/testsigma/addons/Operations/DeleteOperation.java
  • mongodb_query_executor/src/main/java/com/testsigma/addons/Operations/FindOperation.java
  • mongodb_query_executor/src/main/java/com/testsigma/addons/Operations/IndexOperation.java
  • mongodb_query_executor/src/main/java/com/testsigma/addons/Operations/InsertOperation.java
  • mongodb_query_executor/src/main/java/com/testsigma/addons/Operations/UpdateOperation.java
  • mongodb_query_executor/src/main/java/com/testsigma/addons/Utils/MongoOperation.java
  • mongodb_query_executor/src/main/java/com/testsigma/addons/Utils/MongoOperationFactory.java
  • mongodb_query_executor/src/main/java/com/testsigma/addons/android/MongoDB_QueryExecutor.java
  • mongodb_query_executor/src/main/java/com/testsigma/addons/android/MongoDB_QueryExecutorAndStoresInaVariable.java
  • mongodb_query_executor/src/main/java/com/testsigma/addons/ios/MongoDB_QueryExecutor.java
  • mongodb_query_executor/src/main/java/com/testsigma/addons/ios/MongoDB_QueryExecutorAndStoresInaVariable.java
  • mongodb_query_executor/src/main/java/com/testsigma/addons/mobileweb/MongoDB_QueryExecutor.java
  • mongodb_query_executor/src/main/java/com/testsigma/addons/mobileweb/MongoDB_QueryExecutorAndStoresInaVariable.java
  • mongodb_query_executor/src/main/java/com/testsigma/addons/restapi/MongoDB_QueryExecutor.java
  • mongodb_query_executor/src/main/java/com/testsigma/addons/restapi/MongoDB_QueryExecutorAndStoresInaVariable.java
  • mongodb_query_executor/src/main/java/com/testsigma/addons/web/MongoDB_QueryExecutor.java
  • mongodb_query_executor/src/main/java/com/testsigma/addons/web/MongoDB_QueryExecutorAndStoresInaVariable.java
  • mongodb_query_executor/src/main/java/com/testsigma/addons/windows/MongoDB_QueryExecutor.java
  • mongodb_query_executor/src/main/java/com/testsigma/addons/windows/MongoDB_QueryExecutorAndStoresInaVariable.java
  • mongodb_query_executor/src/main/resources/testsigma-sdk.properties

Comment on lines +38 to +41
MongoClientURI uri = new MongoClientURI(connection);
MongoClient mongoClient = new MongoClient(uri);

Set<String> colls = mongoClient.getDB(database).getCollectionNames();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Close MongoClient to prevent resource leaks.

The client created on Line 39 is never closed; repeated executions can leak sockets/threads.

Suggested fix
-			MongoClientURI uri = new MongoClientURI(connection);
-			MongoClient mongoClient = new MongoClient(uri);
-
-			Set<String> colls = mongoClient.getDB(database).getCollectionNames();
+			MongoClientURI uri = new MongoClientURI(connection);
+			try (MongoClient mongoClient = new MongoClient(uri)) {
+				Set<String> colls = mongoClient.getDB(database).getCollectionNames();
+				sb.append("<br>");
+				for (String collections : colls) {
+					sb.append(collections);
+					sb.append("<br>");
+				}
+			}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/ios/MongoDB_GetListofCollectionsWithConnectionURL.java`
around lines 38 - 41, The MongoClient created via new MongoClient(uri) (variable
mongoClient in MongoDB_GetListofCollectionsWithConnectionURL.java) is not
closed, risking resource leaks; update the code to ensure mongoClient.close() is
always called after using mongoClient.getDB(database).getCollectionNames() —
either wrap the client creation and usage in a try-with-resources (if the driver
supports AutoCloseable) or use a try { ... } finally { mongoClient.close(); } so
the MongoClient instance is reliably closed on success or exception.

Comment on lines +30 to +52
try{
String connection = testData1.getValue().toString();

MongoClientURI uri = new MongoClientURI(connection);
MongoClient mongoClient = new MongoClient(uri);

MongoCursor<String> dbsCursord = mongoClient.listDatabaseNames().iterator();

sb.append("<br>");
while(dbsCursord.hasNext()) {
sb.append(dbsCursord.next());
sb.append("<br>");
}
setSuccessMessage("Successfully fetched the databases list: " +sb.toString());
logger.info("Successfully fetched the databases list: " +sb.toString());
}
catch (Exception e){
String errorMessage = ExceptionUtils.getStackTrace(e);
result = Result.FAILED;
setErrorMessage(errorMessage);
logger.warn(errorMessage);
}
return result;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Resource leak: MongoClient and MongoCursor are never closed.

Both MongoClient and MongoCursor hold connections/resources that must be released. Failing to close them will exhaust the connection pool over time. Use try-with-resources for automatic cleanup.

🐛 Proposed fix with try-with-resources
 		try{
+			StringBuffer sb = new StringBuffer();
 			String connection = testData1.getValue().toString();
 
 			MongoClientURI uri = new MongoClientURI(connection);
-			MongoClient mongoClient = new MongoClient(uri);
-			
-			MongoCursor<String> dbsCursord = mongoClient.listDatabaseNames().iterator();
-			
-			sb.append("<br>");
-			while(dbsCursord.hasNext()) {
-			      sb.append(dbsCursord.next());
-			      sb.append("<br>");
-			 }
+			try (MongoClient mongoClient = new MongoClient(uri);
+			     MongoCursor<String> dbsCursor = mongoClient.listDatabaseNames().iterator()) {
+				sb.append("<br>");
+				while (dbsCursor.hasNext()) {
+					sb.append(dbsCursor.next());
+					sb.append("<br>");
+				}
+			}
 			setSuccessMessage("Successfully fetched the databases list: " +sb.toString());
 			logger.info("Successfully fetched the databases list: " +sb.toString());
 		}
 		catch (Exception e){
 			String errorMessage = ExceptionUtils.getStackTrace(e);
 			result = Result.FAILED;
 			setErrorMessage(errorMessage);
-			logger.warn(errorMessage);
+			logger.error(errorMessage);
 		}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/ios/MongoDB_GetListofDatabases.java`
around lines 30 - 52, The code in MongoDB_GetListofDatabases is leaking
resources because MongoClient (mongoClient) and MongoCursor (dbsCursord) are
never closed; change the logic in the method to use try-with-resources (or
ensure finally blocks) to close both MongoClient and the MongoCursor: create
MongoClient and obtain the MongoCursor inside a try(...) block so they are
auto-closed, keep the existing sb population and logging
(setSuccessMessage/logger.info) inside the try, and move exception handling to
catch any thrown exceptions (preserving setErrorMessage/logger.warn) — reference
the MongoClient, MongoCursor<String> dbsCursord, and MongoClientURI usages to
locate the code to modify.

Comment on lines +38 to +40
MongoClient mongoClient = new MongoClient(uri);

DB db = mongoClient.getDB(testData1.getValue().toString());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Resource leak: MongoClient is never closed.

The MongoClient holds connection pool resources and must be closed after use to prevent connection leaks. This can exhaust connection limits and cause failures under repeated execution.

🐛 Proposed fix using try-with-resources
-			MongoClientURI uri = new MongoClientURI(connection);
-			MongoClient mongoClient = new MongoClient(uri);
-
-			DB db = mongoClient.getDB(testData1.getValue().toString());
-
-			Set<String> colls = db.getCollectionNames();
-			
-			sb.append("<br>");
-			for (String collections : colls) {
-				sb.append(collections);
-			}
-			setSuccessMessage("Successfully fetched the collection list: " +sb.toString());
-			logger.info("Successfully fetched the collection list: " +sb.toString() +connection);
+			MongoClientURI uri = new MongoClientURI(connection);
+			try (MongoClient mongoClient = new MongoClient(uri)) {
+				DB db = mongoClient.getDB(testData1.getValue().toString());
+
+				Set<String> colls = db.getCollectionNames();
+				
+				sb.append("<br>");
+				for (String collections : colls) {
+					sb.append(collections).append(", ");
+				}
+				setSuccessMessage("Successfully fetched the collection list: " + sb.toString());
+				logger.info("Successfully fetched the collection list.");
+			}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/mobileweb/MongoDB_GetListofCollection.java`
around lines 38 - 40, The MongoClient instance (mongoClient) is never closed,
causing a resource leak; update the MongoDB_GetListofCollection code to ensure
mongoClient is closed by using try-with-resources (or a finally block) around
the client usage so DB db = mongoClient.getDB(...) and subsequent operations
occur inside the try and the client is automatically closed afterward; reference
the MongoClient variable name (mongoClient) and the DB usage (getDB) to insert
the resource-safe block.

Comment on lines +38 to +45
MongoClientURI uri = new MongoClientURI(connection);
MongoClient mongoClient = new MongoClient(uri);

DB db = mongoClient.getDB(database);

DBCollection collection = db.getCollection(testData3.getValue().toString());

DBCursor iterDoc = collection.find();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Resource leak: MongoClient and DBCursor are never closed.

Both MongoClient and DBCursor hold connection resources. Failing to close them can exhaust the connection pool. Use try-with-resources or explicit close() in a finally block.

Proposed fix using try-with-resources
-			MongoClientURI uri = new MongoClientURI(connection);
-			MongoClient mongoClient = new MongoClient(uri);
-			
-			DB db = mongoClient.getDB(database);
-
-			DBCollection collection = db.getCollection(testData3.getValue().toString());
-
-			DBCursor iterDoc = collection.find();
-			Iterator it = iterDoc.iterator();
-			sb.append("<br>");
-			while (it.hasNext()) {
-				sb.append(it.next());
-				sb.append("<br>");
-			}
+			MongoClientURI uri = new MongoClientURI(connection);
+			try (MongoClient mongoClient = new MongoClient(uri)) {
+				DB db = mongoClient.getDB(database);
+				DBCollection collection = db.getCollection(testData3.getValue().toString());
+				try (DBCursor iterDoc = collection.find()) {
+					sb.append("<br>");
+					while (iterDoc.hasNext()) {
+						sb.append(iterDoc.next());
+						sb.append("<br>");
+					}
+				}
+			}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_nlps/src/main/java/com/testsigma/addons/mobileweb/MongoDB_GetvaluesofCollectionWithConnectionURL.java`
around lines 38 - 45, The MongoClient and DBCursor created in
MongoDB_GetvaluesofCollectionWithConnectionURL (symbols: MongoClientURI,
MongoClient, DB, DBCollection, DBCursor) are never closed; modify the method to
ensure resources are closed by using try-with-resources (or a try/finally)
around the MongoClient and iterate with a try-with-resources or explicit close()
for the DBCursor, so that mongoClient.close() and cursor.close() are always
called even on exceptions; update the code that constructs MongoClient(new
MongoClientURI(connection)) and collection.find() to be inside the
resource-guarded blocks.

@@ -0,0 +1 @@
testsigma-sdk.api.key=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJiODUzOWIxMi0wOWM1LTc0YTktNTZjMy0xMTQxZjFmYjY0M2UiLCJ1bmlxdWVJZCI6IjY2OCIsImV4dGVybmFsVGVuYW50SWQiOiIyODE3In0.-bnJJxCofkdvNudhEGaR329W03CyYqtClsGFh4xBdNL5zS7hLVmR_u27-6AxMXYxt-SE9JANrzytYJhAwTvGEQ No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Remove committed API key from source control immediately.

A real credential is hardcoded in the repository. This is a direct secret-leak and unauthorized-access risk. Replace it with a placeholder, load the value from environment/secret storage at runtime, and rotate/revoke this exposed key now.

🔐 Proposed fix
-testsigma-sdk.api.key=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJiODUzOWIxMi0wOWM1LTc0YTktNTZjMy0xMTQxZjFmYjY0M2UiLCJ1bmlxdWVJZCI6IjY2OCIsImV4dGVybmFsVGVuYW50SWQiOiIyODE3In0.-bnJJxCofkdvNudhEGaR329W03CyYqtClsGFh4xBdNL5zS7hLVmR_u27-6AxMXYxt-SE9JANrzytYJhAwTvGEQ
+testsigma-sdk.api.key=${TESTSIGMA_SDK_API_KEY}
📝 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
testsigma-sdk.api.key=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJiODUzOWIxMi0wOWM1LTc0YTktNTZjMy0xMTQxZjFmYjY0M2UiLCJ1bmlxdWVJZCI6IjY2OCIsImV4dGVybmFsVGVuYW50SWQiOiIyODE3In0.-bnJJxCofkdvNudhEGaR329W03CyYqtClsGFh4xBdNL5zS7hLVmR_u27-6AxMXYxt-SE9JANrzytYJhAwTvGEQ
testsigma-sdk.api.key=${TESTSIGMA_SDK_API_KEY}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mongodb_nlps/src/main/resources/testsigma-sdk.properties` at line 1, The
committed real API key under the property testsigma-sdk.api.key must be removed
and replaced with a non-sensitive placeholder; update testsigma-sdk.properties
to set testsigma-sdk.api.key=<REPLACE_WITH_ENV>, modify any config-loading code
that reads this property to prefer an environment variable or secret-store
(e.g., process.env.TESTSIGMA_API_KEY or your secret manager) when available,
delete the exposed key from the repository history and rotate/revoke the leaked
credential immediately, and ensure CI/README notes how to supply the real key at
runtime.

import com.testsigma.sdk.annotation.TestData;
import com.testsigma.sdk.annotation.RunTimeData;
import lombok.Data;
import org.apache.commons.lang.exception.ExceptionUtils;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Wrong package for ExceptionUtils - should use commons-lang3.

The import uses org.apache.commons.lang.exception.ExceptionUtils (from deprecated commons-lang), but the POM declares commons-lang3. This will cause a ClassNotFoundException at runtime.

🐛 Proposed fix
-import org.apache.commons.lang.exception.ExceptionUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
📝 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
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_query_executor/src/main/java/com/testsigma/addons/web/MongoDB_QueryExecutorAndStoresInaVariable.java`
at line 15, The import for ExceptionUtils in
MongoDB_QueryExecutorAndStoresInaVariable.java is from the deprecated
commons-lang package; replace the wrong import
org.apache.commons.lang.exception.ExceptionUtils with the commons-lang3
equivalent org.apache.commons.lang3.exception.ExceptionUtils so the class
matches the POM dependency and avoids ClassNotFoundException (search for the
import line and update the ExceptionUtils import accordingly).

Comment on lines +56 to +91
if (queryInput.contains("deleteOne") || queryInput.contains("deleteMany") || queryInput.contains("createIndex") || queryInput.contains("dropIndex") || queryInput.contains("getIndexes")) {
setErrorMessage("Operation not supported.");
return Result.FAILED;
}

MongoOperation operation = MongoOperationFactory.getOperation(queryInput);

if (operation != null) {
result = operation.execute(database, queryInput, sb, logger);
logger.info(queryInput + " : Query executed");

// Extract only the JSON array part from the result
String resultString = sb.toString();
int startIndex = resultString.indexOf("[{");
int endIndex = resultString.lastIndexOf("}]") + 2;

// Extract meaningful JSON result
if (startIndex >= 0 && endIndex > startIndex) {
resultString = resultString.substring(startIndex, endIndex);
}

// Check if the result is meaningful (e.g., avoid storing irrelevant messages like 'No documents were modified')
if (resultString.contains("No documents were modified") || resultString.isEmpty()) {
// If result is not meaningful, do not store it
setErrorMessage("Query executed but no documents were modified or result is empty.");
result = Result.FAILED;
} else {
// Store meaningful result in runtime variable
runTimeData.setKey(runtimeVar.getValue().toString());
runTimeData.setValue(resultString);
setSuccessMessage("Query executed successfully. Result stored in variable " + runtimeVar.getValue().toString() + " = " + resultString);
logger.info("Value stored in variable: " + runtimeVar.getValue().toString() + " = " + resultString);
}
} else {
setErrorMessage("Unsupported query operation. Only 'find', 'insert', 'update', 'aggregate' and 'index' queries are supported. Query: " + queryInput);
result = Result.FAILED;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Index/delete queries are blocked despite being advertised as supported.

Line [56] returns FAILED for delete/index methods before factory dispatch, but Line [90] says those operations are supported. This makes valid queries unreachable.

🔧 Proposed fix
-            // Check for unsupported delete operations
-            if (queryInput.contains("deleteOne") || queryInput.contains("deleteMany") || queryInput.contains("createIndex") || queryInput.contains("dropIndex") || queryInput.contains("getIndexes")) {
-                setErrorMessage("Operation not supported.");
-                return Result.FAILED;
-            }
+            // Let MongoOperationFactory resolve supported operations consistently.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@mongodb_query_executor/src/main/java/com/testsigma/addons/windows/MongoDB_QueryExecutorAndStoresInaVariable.java`
around lines 56 - 91, The early guard that checks queryInput for "deleteOne",
"deleteMany", "createIndex", "dropIndex", "getIndexes" and returns Result.FAILED
prevents legitimate delete/index operations from ever reaching
MongoOperationFactory; remove or adjust that guard so it does not reject
supported operations and instead rely on
MongoOperationFactory.getOperation(queryInput) and the MongoOperation
implementations to accept/deny operations (i.e., delete the blocking condition
around queryInput or whitelist only truly unsupported patterns), ensuring code
paths in MongoDB_QueryExecutorAndStoresInaVariable (the initial if block),
MongoOperationFactory.getOperation, and the MongoOperation.execute
implementations handle delete and index operations consistently and return
appropriate success/error messages.

@@ -0,0 +1 @@
testsigma-sdk.api.key=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyMjMyMmM2Ni04NWYzLWIyN2UtN2FiOS0zM2U2M2Q4OWM1MGIiLCJ1bmlxdWVJZCI6IjM5MTkiLCJpZGVudGl0eUFjY291bnRVVUlkIjoiMzUifQ.8DWXtKi6_n-VgTfNc-m60SHXobxazi_IHEY7gfq0zSByZ9nacT-2T1nS50jJrDhnIOoyAMLmBPSNm8ao9G2K6Q No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Remove committed API key from source control immediately.

Line 1 contains a live credential in a resource file. This is a direct secret leak (repo + built artifact exposure) and should be treated as compromised.

🔐 Proposed secure change
-testsigma-sdk.api.key=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyMjMyMmM2Ni04NWYzLWIyN2UtN2FiOS0zM2U2M2Q4OWM1MGIiLCJ1bmlxdWVJZCI6IjM5MTkiLCJpZGVudGl0eUFjY291bnRVVUlkIjoiMzUifQ.8DWXtKi6_n-VgTfNc-m60SHXobxazi_IHEY7gfq0zSByZ9nacT-2T1nS50jJrDhnIOoyAMLmBPSNm8ao9G2K6Q
+testsigma-sdk.api.key=${TESTSIGMA_SDK_API_KEY}

Also rotate/revoke the exposed key and scrub it from git history.

📝 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
testsigma-sdk.api.key=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyMjMyMmM2Ni04NWYzLWIyN2UtN2FiOS0zM2U2M2Q4OWM1MGIiLCJ1bmlxdWVJZCI6IjM5MTkiLCJpZGVudGl0eUFjY291bnRVVUlkIjoiMzUifQ.8DWXtKi6_n-VgTfNc-m60SHXobxazi_IHEY7gfq0zSByZ9nacT-2T1nS50jJrDhnIOoyAMLmBPSNm8ao9G2K6Q
testsigma-sdk.api.key=${TESTSIGMA_SDK_API_KEY}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mongodb_query_executor/src/main/resources/testsigma-sdk.properties` at line
1, Remove the hard-coded secret found as the testsigma-sdk.api.key property in
testsigma-sdk.properties: delete the committed value, replace usage with a
secure retrieval (e.g., read from an environment variable or a secrets manager)
wherever the property is loaded, and update code that references the property
key name to fallback to process/env-based config; rotate/revoke the exposed API
key immediately and scrub the secret from git history (use git filter-repo/BFG)
and CI/artifact stores so the credential is fully removed.

@akhil-testsigma
akhil-testsigma merged commit 39ccaa6 into dev Mar 4, 2026
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.

2 participants