Skip to content

[CUS-11475] Added existing nlp to all application types.#361

Open
ManojTestsigma wants to merge 1 commit intodevfrom
CUS-11475
Open

[CUS-11475] Added existing nlp to all application types.#361
ManojTestsigma wants to merge 1 commit intodevfrom
CUS-11475

Conversation

@ManojTestsigma
Copy link
Copy Markdown
Contributor

@ManojTestsigma ManojTestsigma commented Mar 23, 2026

please review this addon and publish as PUBLIC

Addon name : Add minutes to the specific date time and store the output in specific format
Addon accont: https://jarvis.testsigma.com/ui/tenants/2817/addons
Jira: https://testsigma.atlassian.net/browse/CUS-11475

fix

Summary by CodeRabbit

  • New Features

    • Added datetime manipulation actions across all platforms (Android, iOS, Mobile Web, Salesforce, Windows, Windows Advanced) enabling users to add or subtract minutes from datetime values.
    • Actions support custom input/output datetime formats and store results in runtime variables for use in subsequent test steps.
  • Chores

    • Version bumped from 1.0.3 to 1.0.4.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 23, 2026

📝 Walkthrough

Walkthrough

This PR adds comprehensive time arithmetic functionality to the Testsigma addons framework by introducing AddMinutesToDateTime and SubtractMinutesToDateTime action classes across six platforms (Android, iOS, Mobile Web, Salesforce, Windows, and Windows Advanced). It also increments the project version from 1.0.3 to 1.0.4 in the POM file.

Changes

Cohort / File(s) Summary
Version Management
add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/pom.xml
Updated project version from 1.0.3 to 1.0.4.
Android Platform
add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/android/AddMinutesToDateTime.java, ...android/SubtractMinutesToDateTime.java
Added two AndroidAction classes for datetime arithmetic. Both parse minute values, validate non-negative inputs, distinguish between time-only (LocalTime) and datetime (LocalDateTime) parsing based on format tokens, and store formatted results to runtime variables with comprehensive error handling.
iOS Platform
add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/ios/AddMinutesToDateTime.java, ...ios/SubtractMinutesToDateTime.java
Added two IOSAction classes with identical functionality to Android variants, extending IOSAction base class and using same datetime parsing/formatting logic.
Mobile Web Platform
add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/mobileweb/AddMinutesToDateTime.java, ...mobileweb/SubtractMinutesToDateTime.java
Added two WebAction classes implementing the same datetime arithmetic operations for mobile web contexts, with consistent error handling and runtime variable storage.
Salesforce Platform
add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/salesforce/AddMinutesToDateTime.java, ...salesforce/SubtractMinutesToDateTime.java
Added two SalesforceAction classes with datetime arithmetic logic, consistent with other platforms regarding format detection and minute validation.
Windows Platform
add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/windows/AddMinutesToDateTime.java, ...windows/SubtractMinutesToDateTime.java
Added two WindowsAction classes replicating the core datetime arithmetic pattern across the Windows automation context.
Windows Advanced Platform
add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/windowsadvanced/AddMinutesToDateTime.java, ...windowsadvanced/SubtractMinutesToDateTime.java
Added two WindowsAdvancedAction classes extending the datetime arithmetic functionality to advanced Windows scenarios.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Action as Action Handler
    participant Parser as DateTime Parser
    participant Calculator as Time Calculator
    participant Formatter as Output Formatter
    participant Storage as RunTimeData Storage

    User->>Action: Execute with datetime input & minutes
    Action->>Action: Validate minute value (non-negative)
    alt Validation Failed
        Action->>User: Return FAILED
    else Validation Success
        Action->>Parser: Parse input datetime with format
        alt Parse Failed
            Parser->>Action: Return null
            Action->>User: Return FAILED
        else Parse Success
            Parser->>Calculator: Return parsed LocalTime/LocalDateTime
            Calculator->>Calculator: Add or subtract minutes
            Calculator->>Formatter: Return updated temporal
            Formatter->>Formatter: Format with output pattern
            alt Format Failed
                Formatter->>Action: Return null
                Action->>User: Return FAILED
            else Format Success
                Formatter->>Storage: Provide formatted string
                Storage->>Storage: Store under variable name
                Action->>User: Return SUCCESS
            end
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • Ganesh-Testsigma
  • vigneshtestsigma

Poem

🐰 A rabbit's ode to temporal travels:

Minutes tick and moments dance,
Through formats, LocalTime's trance,
Add and subtract with platform grace,
Six worlds now track the ticking race! ✨⏰

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title claims to add existing NLP to all application types, but the changeset actually adds new action classes (AddMinutesToDateTime and SubtractMinutesToDateTime) for multiple platforms. Update the title to accurately reflect the main change, such as: 'Add AddMinutesToDateTime and SubtractMinutesToDateTime actions across all application types' or 'Implement minute addition/subtraction datetime actions for all platforms'.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch CUS-11475

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.


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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 14

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/android/AddMinutesToDateTime.java`:
- Around line 87-113: The try block around DateTimeFormatter.ofPattern(...) and
the parsing in AddMinutesToDateTime (the code that uses
inputFormatter/outputFormatter, LocalTime.parse/LocalDateTime.parse, plusMinutes
and format) must also handle IllegalArgumentException thrown for invalid pattern
strings; update the error handling by adding a catch for
IllegalArgumentException (or use a multi-catch: catch (DateTimeParseException |
IllegalArgumentException e)) and in that catch log a clear warning (logger.warn)
with the message, call setErrorMessage(...) with the same actionable text, and
return null—mirroring the existing DateTimeParseException handling so invalid
format patterns are caught and reported.

In
`@add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/android/SubtractMinutesToDateTime.java`:
- Around line 17-18: The user-facing annotation text for
SubtractMinutesToDateTime incorrectly uses "to" instead of "from"; update the
`@Action` annotation on class SubtractMinutesToDateTime by changing the actionText
and description strings to use "from" (e.g., "Subtract minute minutes from the
input-datetime..." and "...Subtracts specified minutes from a given input
datetime...") and scan the class for any other user-facing strings or Javadoc in
SubtractMinutesToDateTime that repeat "to" so they are also changed to "from"
for consistency.
- Around line 90-106: The branch that checks inputFormatString.contains("HH") is
unreliable; replace it by parsing with the DateTimeFormatter.parseBest approach:
use inputFormatter.parseBest(dateTimeString, LocalDateTime::from,
LocalTime::from) to get a TemporalAccessor, test whether the parsed result is a
LocalTime or LocalDateTime, then subtract minutesToSubtract and format with
DateTimeFormatter.ofPattern(outputFormatString) as before; update the logic
inside the SubtractMinutesToDateTime class where inputFormatter,
outputFormatString, minutesToSubtract and logger are used so you call parseBest
on inputFormatter, cast to LocalDateTime or LocalTime accordingly, do
minusMinutes, log the appropriate message, and return the formatted string.

In
`@add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/ios/AddMinutesToDateTime.java`:
- Around line 90-103: The routing logic using inputFormatString is too
permissive: before calling LocalTime.parse(dateTimeString, inputFormatter) (and
creating newTime), ensure the format contains no date tokens (e.g., "y", "yyyy",
"M", "MM", "d", "dd") so only pure time formats hit the LocalTime branch;
otherwise route to LocalDateTime.parse(dateTimeString, inputFormatter) (the
existing LocalDateTime/newDateTime branch). Update the condition around
inputFormatString (used with LocalTime.parse and LocalDateTime.parse) to check
for absence of date tokens or invert logic to detect date+time formats and
dispatch accordingly, keeping DateTimeFormatter outputFormatter and the
minutesToAdd logic intact.

In
`@add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/ios/SubtractMinutesToDateTime.java`:
- Around line 17-18: Update the user-facing grammar in the
SubtractMinutesToDateTime action annotation: change the phrase "Subtract ...
minutes to the input-datetime" to "Subtract ... minutes from the input-datetime"
in both the actionText and the description attributes of the `@Action` on the
SubtractMinutesToDateTime class so the message reads correctly to users.

In
`@add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/mobileweb/AddMinutesToDateTime.java`:
- Around line 90-103: The branch selector currently uses
inputFormatString.contains("HH"|"mm"|"ss") and incorrectly chooses
LocalTime.parse for datetime patterns; update the condition so it only selects
the LocalTime path when the format contains time tokens AND does NOT contain any
date tokens (e.g., "y", "yyyy", "yy", "M", "MM", "d", "dd", "D", "u" etc.).
Specifically, change the check around inputFormatString (the if that controls
LocalTime.parse and LocalDateTime.parse) to confirm absence of date-specifier
substrings before calling LocalTime.parse, otherwise use LocalDateTime.parse and
the existing date-time handling.

In
`@add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/mobileweb/SubtractMinutesToDateTime.java`:
- Around line 90-106: The branch selection based on inputFormatString's
"HH/mm/ss" incorrectly treats full datetime patterns as time-only causing
LocalTime.parse to throw; update the logic in SubtractMinutesToDateTime (where
inputFormatString is checked and LocalTime.parse/LocalDateTime.parse are used)
to first detect date components (e.g., 'y', 'M', 'd', 'D', 'E') and only treat
the input as time-only when time tokens are present AND no date tokens exist, or
alternatively attempt LocalTime.parse in a try-catch and on
DateTimeParseException fall back to parsing with LocalDateTime.parse; ensure the
outputFormatter usage remains the same and log messages (logger.info) are
preserved for both branches.

In
`@add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/salesforce/AddMinutesToDateTime.java`:
- Around line 86-115: The addMinutesToDateTime method uses a brittle
format-string contains heuristic and should instead use
DateTimeFormatter.parseBest to detect whether input parses to a LocalDateTime or
LocalTime; replace the branch that checks inputFormatString.contains(...) with
parsing via DateTimeFormatter inputFormatter =
DateTimeFormatter.ofPattern(inputFormatString) and
inputFormatter.parseBest(dateTimeString, LocalDateTime::from, LocalTime::from)
to obtain either a LocalDateTime or LocalTime, then add minutes on the
appropriate type and format with outputFormatter; update error handling to
remain the same and consider extracting this parse-and-normalize behavior into a
shared utility used by addMinutesToDateTime and other add/subtract methods
(e.g., a method like parseToDateTimeOrTime).

In
`@add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/salesforce/SubtractMinutesToDateTime.java`:
- Around line 90-106: The branch condition misclassifies full datetimes as
time-only; update the logic that checks inputFormatString so it looks for date
component tokens (e.g., "y", "yyyy", "M", "MM", "d", "dd" or specifically
"yyyy"/"MM"/"dd") and route to LocalDateTime.parse/LocalDateTime.minusMinutes
when any date tokens are present; only use
LocalTime.parse/LocalTime.minusMinutes when the format contains no date tokens.
Change the branches around LocalTime.parse and LocalDateTime.parse accordingly
(references: inputFormatString, LocalTime.parse, LocalDateTime.parse,
newTime.format, newDateTime.format).

In
`@add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/windows/AddMinutesToDateTime.java`:
- Around line 90-103: The branch incorrectly treats any format containing time
tokens as time-only; update the condition that decides between LocalTime.parse
and LocalDateTime.parse so it only uses LocalTime when the inputFormatString
contains time tokens (e.g., "HH","mm","ss") AND does NOT contain date tokens
(e.g., "y","M","d" or full tokens like "yyyy","MM","dd"); locate the check using
inputFormatString and switch to a clearer predicate (e.g., check for absence of
date tokens or use a regex) and then call LocalTime.parse(dateTimeString,
inputFormatter) only for pure-time formats, otherwise use LocalDateTime.parse as
currently done for datetime strings and format with outputFormatter.

In
`@add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/windows/SubtractMinutesToDateTime.java`:
- Around line 90-106: The current guard using inputFormatString.contains("HH")
|| contains("mm") || contains("ss") is inverted and will try LocalTime.parse on
values that include dates; change the check to detect absence of date components
instead: if the inputFormatString does NOT contain any of 'y', 'M', or 'd'
(e.g., !inputFormatString.contains("y") && !inputFormatString.contains("M") &&
!inputFormatString.contains("d")) then treat as time-only and use
LocalTime.parse(...) / time.minusMinutes(...), otherwise parse as LocalDateTime
using LocalDateTime.parse(...) / dateTime.minusMinutes(...); keep using
inputFormatter, minutesToSubtract, outputFormatter and
new...format(outputFormatter) as before and update the conditional in the
SubtractMinutesToDateTime code accordingly.

In
`@add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/windowsadvanced/AddMinutesToDateTime.java`:
- Around line 90-103: The branch condition for time-only parsing is inverted:
currently it routes formats containing time tokens to LocalTime.parse (using
inputFormatter), which fails when the format also contains date tokens like 'y',
'M', or 'd'; change the condition to detect true time-only formats by confirming
the ABSENCE of date tokens (e.g. ensure !(inputFormatString.contains("y") ||
inputFormatString.contains("M") || inputFormatString.contains("d"))), then use
LocalTime.parse for that branch and LocalDateTime.parse for formats containing
date tokens; update the condition around inputFormatString (and keep using
inputFormatter, LocalTime.parse, LocalDateTime.parse, plusMinutes, and
outputFormatter) so date-bearing formats go to LocalDateTime.parse and pure-time
formats go to LocalTime.parse.

In
`@add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/windowsadvanced/SubtractMinutesToDateTime.java`:
- Around line 17-18: The actionText in the `@Action` annotation of the
SubtractMinutesToDateTime class is worded incorrectly ("Subtract minute minutes
to the input-datetime..."); update the actionText string to read "Subtract
minute minutes from the input-datetime with input-datetime-format, convert to
output-datetime-format format, and store it in a runtime variable variable-name"
so the user-facing instruction uses "from" instead of "to" (leave the
description and other identifiers unchanged).
- Around line 90-103: The current heuristic in SubtractMinutesToDateTime uses
inputFormatString.contains("HH"|"mm"|"ss") and incorrectly sends mixed date-time
patterns (e.g., "yyyy-MM-dd HH:mm:ss") to LocalTime.parse; update the condition
to detect both date and time tokens: check for presence of any date-pattern
tokens (e.g., "y", "yyyy", "M", "MM", "d", "dd") AND any time-pattern tokens
("H","HH","m","mm","s","ss"); if both date AND time tokens are present, route to
LocalDateTime.parse(dateTimeString, inputFormatter) and use
newDateTime.minusMinutes(minutesToSubtract), otherwise if only time tokens use
LocalTime.parse(...) and newTime.minusMinutes(...), and if only date tokens
handle accordingly (or throw a clear error). Ensure you update the branches
around inputFormatter, LocalTime.parse, LocalDateTime.parse, newTime/newDateTime
and the returned formatted result.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f38f005b-d3db-4ca0-a0de-4c2b3dbe5cd2

📥 Commits

Reviewing files that changed from the base of the PR and between 360c124 and 476b8ef.

📒 Files selected for processing (13)
  • add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/pom.xml
  • add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/android/AddMinutesToDateTime.java
  • add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/android/SubtractMinutesToDateTime.java
  • add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/ios/AddMinutesToDateTime.java
  • add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/ios/SubtractMinutesToDateTime.java
  • add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/mobileweb/AddMinutesToDateTime.java
  • add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/mobileweb/SubtractMinutesToDateTime.java
  • add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/salesforce/AddMinutesToDateTime.java
  • add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/salesforce/SubtractMinutesToDateTime.java
  • add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/windows/AddMinutesToDateTime.java
  • add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/windows/SubtractMinutesToDateTime.java
  • add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/windowsadvanced/AddMinutesToDateTime.java
  • add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/windowsadvanced/SubtractMinutesToDateTime.java

Comment on lines +87 to +113
try {
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern(inputFormatString);

if (inputFormatString.contains("HH") || inputFormatString.contains("mm") || inputFormatString.contains("ss")) {
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern(outputFormatString);
LocalTime time = LocalTime.parse(dateTimeString, inputFormatter);
LocalTime newTime = time.plusMinutes(minutesToAdd);
logger.info("Successfully added minutes to the input time");

return newTime.format(outputFormatter);

} else {

DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern(outputFormatString);
LocalDateTime dateTime = LocalDateTime.parse(dateTimeString, inputFormatter);

LocalDateTime newDateTime = dateTime.plusMinutes(minutesToAdd);
logger.info("Successfully added minutes to the input datetime");

return newDateTime.format(outputFormatter);
}

} catch (DateTimeParseException e) {
String errorMessage = "Invalid date/time format. Please use the format: " + inputFormatString + ". Error: " + e.getMessage();
logger.warn(errorMessage);
setErrorMessage(errorMessage);
return null;
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 | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's locate and examine the full method implementation
find . -type f -name "AddMinutesToDateTime.java" | head -5

Repository: testsigmahq/testsigma-addons

Length of output: 1887


🏁 Script executed:

# Check for any test files related to this class
find . -type f -name "*AddMinutesToDateTime*" | head -10

Repository: testsigmahq/testsigma-addons

Length of output: 1887


🏁 Script executed:

# Search for the execute method and error handling context
rg -A 20 "public.*execute" add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/ || echo "Pattern not found in that path"

Repository: testsigmahq/testsigma-addons

Length of output: 1887


🏁 Script executed:

# List files in the repository to understand structure
git ls-files | grep -i addminutes | head -20

Repository: testsigmahq/testsigma-addons

Length of output: 1887


🏁 Script executed:

# Look for the java file directly
git ls-files | grep "\.java$" | grep -i datetime

Repository: testsigmahq/testsigma-addons

Length of output: 1887


🌐 Web query:

DateTimeFormatter.ofPattern IllegalArgumentException exceptions Java 8

💡 Result:

DateTimeFormatter.ofPattern(String pattern) in Java 8 throws IllegalArgumentException when the provided pattern string is invalid. This occurs during the parsing of the pattern by DateTimeFormatterBuilder.appendPattern(String), which internally processes the pattern letters and symbols. Common causes include: - Unknown or unsupported pattern letters (e.g., invalid characters not defined in the pattern letter table like 'O' in some contexts, though primarily seen in SimpleDateFormat; for DateTimeFormatter, any undefined letter). - Invalid counts of pattern letters for specific fields (e.g., more than allowed letters for certain zone formats, as noted: "Any other count of letters throws IllegalArgumentException"). - Malformed patterns, such as incorrect use of quotes for literals or adjacent fields causing parsing conflicts (e.g., patterns with digit literals after numeric fields like "yyyyMM'00'" may fail due to known bugs in Java 8, leading to parse exceptions but related to pattern validation). Valid pattern letters (A-Z, a-z) are reserved, and the count determines the format (e.g., 1-3 for short text, 4 for full). Use single quotes ' for literals (escape with ''). Examples of invalid patterns triggering IllegalArgumentException: - Undefined letters. - Excessive letters for fields like zone ID (e.g., more than 2 for ID). Note: Some parsing issues (e.g., adjacent digits) result in DateTimeParseException at runtime, not IllegalArgumentException at formatter creation. Known Java 8 bugs (JDK-8031085, JDK-8032491) affect certain patterns but were fixed in Java 9. To avoid: Consult the official pattern documentation and test patterns. Use DateTimeFormatterBuilder for complex cases.

Citations:


Catch IllegalArgumentException from invalid pattern strings alongside DateTimeParseException.

DateTimeFormatter.ofPattern() throws IllegalArgumentException when the pattern string is invalid (undefined letters, excessive letter counts, malformed syntax). This exception occurs before any parsing attempt and is currently uncaught, allowing invalid patterns to propagate unhandled instead of being caught and logged with actionable messaging.

Proposed fix
-    } catch (DateTimeParseException e) {
+    } catch (IllegalArgumentException | DateTimeParseException e) {
       String errorMessage = "Invalid date/time format. Please use the format: " + inputFormatString + ". Error: " + e.getMessage();
       logger.warn(errorMessage);
       setErrorMessage(errorMessage);
       return null;
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/android/AddMinutesToDateTime.java`
around lines 87 - 113, The try block around DateTimeFormatter.ofPattern(...) and
the parsing in AddMinutesToDateTime (the code that uses
inputFormatter/outputFormatter, LocalTime.parse/LocalDateTime.parse, plusMinutes
and format) must also handle IllegalArgumentException thrown for invalid pattern
strings; update the error handling by adding a catch for
IllegalArgumentException (or use a multi-catch: catch (DateTimeParseException |
IllegalArgumentException e)) and in that catch log a clear warning (logger.warn)
with the message, call setErrorMessage(...) with the same actionable text, and
return null—mirroring the existing DateTimeParseException handling so invalid
format patterns are caught and reported.

Comment on lines +17 to +18
@Action(actionText = "Subtract minute minutes to the input-datetime with input-datetime-format, convert to output-datetime-format format, and store it in a runtime variable variable-name",
description = "Subtracts specified minutes to a given input datetime, converts the resulting datetime to a specified date-time format, and stores it in a runtime variable",
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 | 🟡 Minor

Use "from" in the subtraction metadata.

These strings are user-facing, and both actionText and description currently read as "Subtract ... to" instead of "from".

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

In
`@add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/android/SubtractMinutesToDateTime.java`
around lines 17 - 18, The user-facing annotation text for
SubtractMinutesToDateTime incorrectly uses "to" instead of "from"; update the
`@Action` annotation on class SubtractMinutesToDateTime by changing the actionText
and description strings to use "from" (e.g., "Subtract minute minutes from the
input-datetime..." and "...Subtracts specified minutes from a given input
datetime...") and scan the class for any other user-facing strings or Javadoc in
SubtractMinutesToDateTime that repeat "to" so they are also changed to "from"
for consistency.

Comment on lines +90 to +106
if (inputFormatString.contains("HH") || inputFormatString.contains("mm") || inputFormatString.contains("ss")) {
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern(outputFormatString);
LocalTime time = LocalTime.parse(dateTimeString, inputFormatter);
LocalTime newTime = time.minusMinutes(minutesToSubtract);
logger.info("Successfully subtracted minutes from the input time");

return newTime.format(outputFormatter);

} else {

DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern(outputFormatString);
LocalDateTime dateTime = LocalDateTime.parse(dateTimeString, inputFormatter);

LocalDateTime newDateTime = dateTime.minusMinutes(minutesToSubtract);
logger.info("Successfully subtracted minutes from the input datetime");

return newDateTime.format(outputFormatter);
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

🧩 Analysis chain

🏁 Script executed:

# First, let's find and read the full method context
find . -type f -name "SubtractMinutesToDateTime.java" | head -5

Repository: testsigmahq/testsigma-addons

Length of output: 1887


🏁 Script executed:

# Get the file size and read the relevant section with context
wc -l add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/android/SubtractMinutesToDateTime.java

Repository: testsigmahq/testsigma-addons

Length of output: 1887


🏁 Script executed:

# Read the entire file to understand context
cat -n add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/android/SubtractMinutesToDateTime.java

Repository: testsigmahq/testsigma-addons

Length of output: 1887


Use DateTimeFormatter.parseBest() instead of string matching to distinguish date+time from time-only formats.

The contains("HH") check is an unreliable discriminator that causes misrouting. Formats like yyyy-MM-dd HH:mm contain these tokens but represent full datetimes, not times—parsing them as LocalTime will fail. Time-only formats like hh a (12-hour with AM/PM) don't contain HH, so they incorrectly route to the LocalDateTime branch and also fail.

Replace the conditional logic with DateTimeFormatter.parseBest(dateTimeString, LocalDateTime::from, LocalTime::from), which safely attempts to parse as LocalDateTime first and falls back to LocalTime when date fields are absent.

Proposed fix
-            if (inputFormatString.contains("HH") || inputFormatString.contains("mm") || inputFormatString.contains("ss")) {
-                DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern(outputFormatString);
-                LocalTime time = LocalTime.parse(dateTimeString, inputFormatter);
-                LocalTime newTime = time.minusMinutes(minutesToSubtract);
-                logger.info("Successfully subtracted minutes from the input time");
-
-                return newTime.format(outputFormatter);
-
-            } else {
-
-                DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern(outputFormatString);
-                LocalDateTime dateTime = LocalDateTime.parse(dateTimeString, inputFormatter);
-
-                LocalDateTime newDateTime = dateTime.minusMinutes(minutesToSubtract);
-                logger.info("Successfully subtracted minutes from the input datetime");
-
-                return newDateTime.format(outputFormatter);
-            }
+            DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern(outputFormatString);
+            java.time.temporal.TemporalAccessor parsed =
+                    inputFormatter.parseBest(dateTimeString, LocalDateTime::from, LocalTime::from);
+
+            if (parsed instanceof LocalDateTime) {
+                LocalDateTime newDateTime = ((LocalDateTime) parsed).minusMinutes(minutesToSubtract);
+                logger.info("Successfully subtracted minutes from the input datetime");
+                return newDateTime.format(outputFormatter);
+            }
+
+            LocalTime newTime = ((LocalTime) parsed).minusMinutes(minutesToSubtract);
+            logger.info("Successfully subtracted minutes from the input time");
+            return newTime.format(outputFormatter);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/android/SubtractMinutesToDateTime.java`
around lines 90 - 106, The branch that checks inputFormatString.contains("HH")
is unreliable; replace it by parsing with the DateTimeFormatter.parseBest
approach: use inputFormatter.parseBest(dateTimeString, LocalDateTime::from,
LocalTime::from) to get a TemporalAccessor, test whether the parsed result is a
LocalTime or LocalDateTime, then subtract minutesToSubtract and format with
DateTimeFormatter.ofPattern(outputFormatString) as before; update the logic
inside the SubtractMinutesToDateTime class where inputFormatter,
outputFormatString, minutesToSubtract and logger are used so you call parseBest
on inputFormatter, cast to LocalDateTime or LocalTime accordingly, do
minusMinutes, log the appropriate message, and return the formatted string.

Comment on lines +90 to +103
if (inputFormatString.contains("HH") || inputFormatString.contains("mm") || inputFormatString.contains("ss")) {
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern(outputFormatString);
LocalTime time = LocalTime.parse(dateTimeString, inputFormatter);
LocalTime newTime = time.plusMinutes(minutesToAdd);
logger.info("Successfully added minutes to the input time");

return newTime.format(outputFormatter);

} else {

DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern(outputFormatString);
LocalDateTime dateTime = LocalDateTime.parse(dateTimeString, inputFormatter);

LocalDateTime newDateTime = dateTime.plusMinutes(minutesToAdd);
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

🧩 Analysis chain

🏁 Script executed:

git ls-files | grep -i "AddMinutesToDateTime"

Repository: testsigmahq/testsigma-addons

Length of output: 1887


🏁 Script executed:

cat -n add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/ios/AddMinutesToDateTime.java

Repository: testsigmahq/testsigma-addons

Length of output: 1887


🏁 Script executed:

# Verify LocalTime.parse() behavior with different format patterns
python3 << 'EOF'
# LocalTime.parse() in Java only accepts time-only formats
# Let's document what would happen with different patterns:

formats_to_test = [
    "HH:mm",                    # time only - should work with LocalTime
    "HH:mm:ss",                 # time only - should work with LocalTime
    "yyyy-MM-dd HH:mm",         # has date - SHOULD FAIL with LocalTime
    "yyyy-MM-dd",               # date only - should fail with LocalTime
    "MM-dd HH:mm:ss",           # mixed - SHOULD FAIL with LocalTime
]

print("Format patterns analysis:")
print("-" * 60)
for fmt in formats_to_test:
    has_date_pattern = any(p in fmt for p in ["yyyy", "MM", "dd", "yy", "D", "d"])
    has_time_pattern = any(p in fmt for p in ["HH", "mm", "ss", "h"])
    
    print(f"\nFormat: {fmt}")
    print(f"  Has date pattern: {has_date_pattern}")
    print(f"  Has time pattern: {has_time_pattern}")
    print(f"  Safe for LocalTime.parse(): {has_time_pattern and not has_date_pattern}")

EOF

Repository: testsigmahq/testsigma-addons

Length of output: 1887


Line 90's condition is insufficient for routing time-only vs. datetime parsing.

The check only verifies presence of time tokens (HH, mm, ss) but ignores date tokens (yyyy, MM, dd, etc.). Formats like yyyy-MM-dd HH:mm pass this condition and incorrectly route to LocalTime.parse() at line 92, which fails because LocalTime cannot parse date components. Add a check to ensure the format contains no date tokens before using LocalTime.parse(), or rewrite the routing logic.

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

In
`@add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/ios/AddMinutesToDateTime.java`
around lines 90 - 103, The routing logic using inputFormatString is too
permissive: before calling LocalTime.parse(dateTimeString, inputFormatter) (and
creating newTime), ensure the format contains no date tokens (e.g., "y", "yyyy",
"M", "MM", "d", "dd") so only pure time formats hit the LocalTime branch;
otherwise route to LocalDateTime.parse(dateTimeString, inputFormatter) (the
existing LocalDateTime/newDateTime branch). Update the condition around
inputFormatString (used with LocalTime.parse and LocalDateTime.parse) to check
for absence of date tokens or invert logic to detect date+time formats and
dispatch accordingly, keeping DateTimeFormatter outputFormatter and the
minutesToAdd logic intact.

Comment on lines +17 to +18
@Action(actionText = "Subtract minute minutes to the input-datetime with input-datetime-format, convert to output-datetime-format format, and store it in a runtime variable variable-name",
description = "Subtracts specified minutes to a given input datetime, converts the resulting datetime to a specified date-time format, and stores it in a runtime variable",
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 | 🟡 Minor

Fix user-facing grammar in action metadata.

The current text says “Subtract ... to ...”; this should read “Subtract ... from ...” in both actionText and description.

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

In
`@add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/ios/SubtractMinutesToDateTime.java`
around lines 17 - 18, Update the user-facing grammar in the
SubtractMinutesToDateTime action annotation: change the phrase "Subtract ...
minutes to the input-datetime" to "Subtract ... minutes from the input-datetime"
in both the actionText and the description attributes of the `@Action` on the
SubtractMinutesToDateTime class so the message reads correctly to users.

Comment on lines +90 to +103
if (inputFormatString.contains("HH") || inputFormatString.contains("mm") || inputFormatString.contains("ss")) {
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern(outputFormatString);
LocalTime time = LocalTime.parse(dateTimeString, inputFormatter);
LocalTime newTime = time.plusMinutes(minutesToAdd);
logger.info("Successfully added minutes to the input time");

return newTime.format(outputFormatter);

} else {

DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern(outputFormatString);
LocalDateTime dateTime = LocalDateTime.parse(dateTimeString, inputFormatter);

LocalDateTime newDateTime = dateTime.plusMinutes(minutesToAdd);
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

🧩 Analysis chain

🏁 Script executed:

find . -name "AddMinutesToDateTime.java" -type f

Repository: testsigmahq/testsigma-addons

Length of output: 1887


🏁 Script executed:

cat -n "add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/windows/AddMinutesToDateTime.java"

Repository: testsigmahq/testsigma-addons

Length of output: 1887


Parser selection logic incorrectly routes datetime formats to time-only parsing.

The condition at line 90 checks if the input format contains time components (HH/mm/ss), but this is insufficient to distinguish between time-only and datetime formats. A datetime format like "yyyy-MM-dd HH:mm:ss" contains both date and time components and would satisfy this condition, causing line 92 to attempt LocalTime.parse(dateTimeString, inputFormatter) with a date+time input string. Since LocalTime expects only time (no date), this will fail with a DateTimeParseException. The correct logic should check whether the format contains only time components and no date components.

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

In
`@add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/windows/AddMinutesToDateTime.java`
around lines 90 - 103, The branch incorrectly treats any format containing time
tokens as time-only; update the condition that decides between LocalTime.parse
and LocalDateTime.parse so it only uses LocalTime when the inputFormatString
contains time tokens (e.g., "HH","mm","ss") AND does NOT contain date tokens
(e.g., "y","M","d" or full tokens like "yyyy","MM","dd"); locate the check using
inputFormatString and switch to a clearer predicate (e.g., check for absence of
date tokens or use a regex) and then call LocalTime.parse(dateTimeString,
inputFormatter) only for pure-time formats, otherwise use LocalDateTime.parse as
currently done for datetime strings and format with outputFormatter.

Comment on lines +90 to +106
if (inputFormatString.contains("HH") || inputFormatString.contains("mm") || inputFormatString.contains("ss")) {
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern(outputFormatString);
LocalTime time = LocalTime.parse(dateTimeString, inputFormatter);
LocalTime newTime = time.minusMinutes(minutesToSubtract);
logger.info("Successfully subtracted minutes from the input time");

return newTime.format(outputFormatter);

} else {

DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern(outputFormatString);
LocalDateTime dateTime = LocalDateTime.parse(dateTimeString, inputFormatter);

LocalDateTime newDateTime = dateTime.minusMinutes(minutesToSubtract);
logger.info("Successfully subtracted minutes from the input datetime");

return newDateTime.format(outputFormatter);
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

🧩 Analysis chain

🏁 Script executed:

cd add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format && find . -name "SubtractMinutesToDateTime.java" -type f

Repository: testsigmahq/testsigma-addons

Length of output: 1887


🏁 Script executed:

cat -n add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/windows/SubtractMinutesToDateTime.java

Repository: testsigmahq/testsigma-addons

Length of output: 1887


🏁 Script executed:

# Test Java LocalTime parsing behavior with datetime strings
python3 << 'EOF'
import subprocess
import tempfile
import os

# Create a test Java program to verify the parsing behavior
test_code = '''
import java.time.LocalTime;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class TimeParsingTest {
    public static void main(String[] args) {
        // Test 1: Try to parse datetime string with LocalTime using datetime pattern
        String datetimeString = "2024-01-15 14:30";
        String datetimePattern = "yyyy-MM-dd HH:mm";
        
        DateTimeFormatter datetimeFormatter = DateTimeFormatter.ofPattern(datetimePattern);
        
        // This should fail or error
        try {
            LocalTime time = LocalTime.parse(datetimeString, datetimeFormatter);
            System.out.println("Test 1 PASSED: Parsed as LocalTime: " + time);
        } catch (Exception e) {
            System.out.println("Test 1 ERROR: " + e.getClass().getSimpleName() + ": " + e.getMessage());
        }
        
        // Test 2: Try parsing time-only string with LocalTime
        String timeString = "14:30:00";
        String timePattern = "HH:mm:ss";
        DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern(timePattern);
        
        try {
            LocalTime time = LocalTime.parse(timeString, timeFormatter);
            System.out.println("Test 2 PASSED: Parsed as LocalTime: " + time);
        } catch (Exception e) {
            System.out.println("Test 2 ERROR: " + e.getMessage());
        }
        
        // Test 3: Verify that guard check contains "HH" and "mm"
        String pattern = "yyyy-MM-dd HH:mm";
        boolean containsHH = pattern.contains("HH");
        boolean containsMM = pattern.contains("mm");
        System.out.println("Test 3: Pattern '" + pattern + "' contains 'HH': " + containsHH + ", contains 'mm': " + containsMM);
    }
}
'''

# Write to temp file and compile/run
with tempfile.TemporaryDirectory() as tmpdir:
    java_file = os.path.join(tmpdir, "TimeParsingTest.java")
    with open(java_file, 'w') as f:
        f.write(test_code)
    
    # Compile
    compile_result = subprocess.run(['javac', java_file], capture_output=True, text=True, cwd=tmpdir)
    if compile_result.returncode != 0:
        print("Compilation failed:", compile_result.stderr)
    else:
        # Run
        run_result = subprocess.run(['java', '-cp', tmpdir, 'TimeParsingTest'], capture_output=True, text=True)
        print(run_result.stdout)
        if run_result.stderr:
            print("STDERR:", run_result.stderr)

EOF

Repository: testsigmahq/testsigma-addons

Length of output: 1887


🌐 Web query:

Java LocalTime.parse() with date components yyyy-MM-dd HH:mm pattern exception

💡 Result:

Yes, using Java's LocalTime.parse with a string containing date components like "yyyy-MM-dd HH:mm" (e.g., "2023-01-01 14:30") throws a DateTimeParseException. LocalTime represents only time-of-day (hour:minute:second.nanos) without date or timezone. The official Java documentation confirms LocalTime.parse(text) expects time-only strings parsed via DateTimeFormatter.ISO_LOCAL_TIME formats like "10:15:30" or "10:15". When parsing a string with date prefixes using a custom formatter like DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"), the parser extracts date fields (ignored by LocalTime.from) but fails to obtain complete time info, resulting in "Text '...' could not be parsed: Unable to obtain LocalTime from TemporalAccessor". To fix: - Extract time portion first: LocalTime.parse(input.substring(11), DateTimeFormatter.ISO_LOCAL_TIME) for "yyyy-MM-dd HH:mm". - Or parse full string to LocalDateTime: LocalDateTime.parse(input, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")). - Use regex or string split to isolate "HH:mm". Exception example: java.time.format.DateTimeParseException: Text '2023-01-01 14:30' could not be parsed: Unable to obtain LocalTime from TemporalAccessor

Citations:


🌐 Web query:

Java LocalTime vs LocalDateTime DateTimeFormatter pattern requirements

💡 Result:

DateTimeFormatter patterns in Java have the same syntax and requirements for both LocalTime and LocalDateTime. The patterns use the same set of letters (e.g., 'H' for hour, 'm' for minute, 'y' for year, 'M' for month) with formatting determined by the number of repeated letters (e.g., 1 for minimal digits, 2 for zero-padded). There are no class-specific pattern requirements or restrictions. LocalTime requires only time-related pattern elements (e.g., "HH:mm:ss"), while LocalDateTime requires both date and time elements (e.g., "yyyy-MM-dd HH:mm:ss"). Using date patterns on LocalTime or vice versa will throw DateTimeParseException or IllegalArgumentException during formatting/parsing if unsupported fields are present. Predefined formatters like ISO_LOCAL_TIME match "HH:mm:ss.SSSSSSSSS" for LocalTime and ISO_LOCAL_DATE_TIME matches "uuuu-MM-ddTHH:mm:ss.SSSSSSSSS" (with 'T') for LocalDateTime. Examples: - LocalTime: DateTimeFormatter.ofPattern("HH:mm:ss").format(LocalTime.now) - LocalDateTime: DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.now)

Citations:


The guard condition is fundamentally flawed and will crash on datetime patterns.

LocalTime.parse() cannot handle strings with date components. A pattern like yyyy-MM-dd HH:mm contains "HH" and "mm", matching this guard, but will throw DateTimeParseException: Unable to obtain LocalTime from TemporalAccessor when executed. The guard must check for the absence of date components (y/M/d), not the presence of time components (H/m/s).

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

In
`@add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/windows/SubtractMinutesToDateTime.java`
around lines 90 - 106, The current guard using inputFormatString.contains("HH")
|| contains("mm") || contains("ss") is inverted and will try LocalTime.parse on
values that include dates; change the check to detect absence of date components
instead: if the inputFormatString does NOT contain any of 'y', 'M', or 'd'
(e.g., !inputFormatString.contains("y") && !inputFormatString.contains("M") &&
!inputFormatString.contains("d")) then treat as time-only and use
LocalTime.parse(...) / time.minusMinutes(...), otherwise parse as LocalDateTime
using LocalDateTime.parse(...) / dateTime.minusMinutes(...); keep using
inputFormatter, minutesToSubtract, outputFormatter and
new...format(outputFormatter) as before and update the conditional in the
SubtractMinutesToDateTime code accordingly.

Comment on lines +90 to +103
if (inputFormatString.contains("HH") || inputFormatString.contains("mm") || inputFormatString.contains("ss")) {
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern(outputFormatString);
LocalTime time = LocalTime.parse(dateTimeString, inputFormatter);
LocalTime newTime = time.plusMinutes(minutesToAdd);
logger.info("Successfully added minutes to the input time");

return newTime.format(outputFormatter);

} else {

DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern(outputFormatString);
LocalDateTime dateTime = LocalDateTime.parse(dateTimeString, inputFormatter);

LocalDateTime newDateTime = dateTime.plusMinutes(minutesToAdd);
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

🧩 Analysis chain

🏁 Script executed:

find . -type f -name "AddMinutesToDateTime.java" | head -5

Repository: testsigmahq/testsigma-addons

Length of output: 1887


🌐 Web query:

Java LocalTime.parse() with date string error behavior documentation

💡 Result:

Java's LocalTime.parse(CharSequence text) method obtains a LocalTime instance from a text string expected to be a valid time in ISO-8601 format (e.g., "10:15" or "10:15:30"), parsed using DateTimeFormatter.ISO_LOCAL_TIME. The string must represent a valid time; otherwise, it throws a DateTimeParseException. For a date string like "2023-01-01" (which lacks time components), LocalTime.parse will fail with DateTimeParseException because it cannot parse date-only content as time-only. Use LocalDate.parse instead for date strings. There is an overloaded parse(CharSequence text, DateTimeFormatter formatter) that allows custom formats, but the no-arg version strictly expects ISO local time format. Official documentation (Java SE 24) confirms: "The string must represent a valid time and is parsed using DateTimeFormatter.ISO_LOCAL_TIME." Throws DateTimeParseException on invalid input.

Citations:


Time-only detection logic is inverted; datetime formats are misrouted to LocalTime parsing.

The condition at line 90 incorrectly identifies datetime formats as time-only based on the presence of time components (HH, mm, ss). Formats like yyyy-MM-dd HH:mm:ss contain these markers and trigger the LocalTime.parse() branch, but their corresponding input strings include date values. This causes LocalTime.parse() to throw DateTimeParseException at line 92 since it cannot parse date-bearing strings.

The condition should check for the absence of date components (y, M, d) to correctly identify time-only formats, not the presence of time components.

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

In
`@add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/windowsadvanced/AddMinutesToDateTime.java`
around lines 90 - 103, The branch condition for time-only parsing is inverted:
currently it routes formats containing time tokens to LocalTime.parse (using
inputFormatter), which fails when the format also contains date tokens like 'y',
'M', or 'd'; change the condition to detect true time-only formats by confirming
the ABSENCE of date tokens (e.g. ensure !(inputFormatString.contains("y") ||
inputFormatString.contains("M") || inputFormatString.contains("d"))), then use
LocalTime.parse for that branch and LocalDateTime.parse for formats containing
date tokens; update the condition around inputFormatString (and keep using
inputFormatter, LocalTime.parse, LocalDateTime.parse, plusMinutes, and
outputFormatter) so date-bearing formats go to LocalDateTime.parse and pure-time
formats go to LocalTime.parse.

Comment on lines +17 to +18
@Action(actionText = "Subtract minute minutes to the input-datetime with input-datetime-format, convert to output-datetime-format format, and store it in a runtime variable variable-name",
description = "Subtracts specified minutes to a given input datetime, converts the resulting datetime to a specified date-time format, and stores it in a runtime variable",
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 | 🟡 Minor

Update action text wording for correctness.

“Subtract ... to ...” should be “Subtract ... from ...” to avoid confusing user-facing instructions.

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

In
`@add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/windowsadvanced/SubtractMinutesToDateTime.java`
around lines 17 - 18, The actionText in the `@Action` annotation of the
SubtractMinutesToDateTime class is worded incorrectly ("Subtract minute minutes
to the input-datetime..."); update the actionText string to read "Subtract
minute minutes from the input-datetime with input-datetime-format, convert to
output-datetime-format format, and store it in a runtime variable variable-name"
so the user-facing instruction uses "from" instead of "to" (leave the
description and other identifiers unchanged).

Comment on lines +90 to +103
if (inputFormatString.contains("HH") || inputFormatString.contains("mm") || inputFormatString.contains("ss")) {
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern(outputFormatString);
LocalTime time = LocalTime.parse(dateTimeString, inputFormatter);
LocalTime newTime = time.minusMinutes(minutesToSubtract);
logger.info("Successfully subtracted minutes from the input time");

return newTime.format(outputFormatter);

} else {

DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern(outputFormatString);
LocalDateTime dateTime = LocalDateTime.parse(dateTimeString, inputFormatter);

LocalDateTime newDateTime = dateTime.minusMinutes(minutesToSubtract);
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

🧩 Analysis chain

🏁 Script executed:

fd -t f "SubtractMinutesToDateTime.java"

Repository: testsigmahq/testsigma-addons

Length of output: 1887


🌐 Web query:

Java LocalTime.parse() error parsing date time format string

💡 Result:

The error in Java's LocalTime.parse when parsing a "date time format string" occurs because LocalTime only handles time-of-day (hours, minutes, seconds, nanos), not dates. Attempting to parse a string with date components (like year-month-day) using LocalTime.parse throws DateTimeParseException, as the parser cannot extract a complete LocalTime from the TemporalAccessor lacking required time fields or having extra date fields. Common causes: 1. Mismatch between input string and formatter pattern: e.g., using "hh:mm" (12-hour clock without AM/PM) on 24-hour input like "15:32:03", or single-digit hours on ISO-expecting double-digit. 2. Using LocalTime.parse on date-inclusive strings meant for LocalDateTime.parse. 3. Incomplete patterns missing fields needed for nano-of-day computation, like using "hh mm" without 'a' for AM/PM. Solutions: - Use correct pattern letters: 'HH:mm:ss' for 24-hour, 'hh:mm a' for 12-hour with AM/PM. - For no formatter (default ISO_LOCAL_TIME): Input must be HH:mm[:ss[.SSS...]] with leading zero for hours. - If string has date, switch to LocalDateTime.parse. - Example fixes: DateTimeFormatter fmt = DateTimeFormatter.ofPattern("HH:mm"); LocalTime time = LocalTime.parse("15:32", fmt); // Works // Wrong: LocalTime.parse("2023-10-01T15:32", fmt); // Fails - use LocalDateTime.parse Official docs confirm LocalTime.parse(text) uses ISO_LOCAL_TIME (HH:mm:ss[.nnnnnnnnn]), and parse(text, formatter) requires matching format.

Citations:


Subtract action fails with datetime formats due to incomplete time-detection heuristic.

Line 90's condition checks only for time pattern presence ("HH", "mm", "ss") but ignores date patterns ("yyyy", "MM", "dd"). A format string like "yyyy-MM-dd HH:mm:ss" contains time patterns, routing to LocalTime.parse(...) at line 92. Since the input string contains date components, LocalTime.parse() throws DateTimeParseException, as it cannot parse date fields.

The heuristic should check for both date AND time patterns to correctly route between LocalTime.parse() and LocalDateTime.parse().

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

In
`@add_minutes_to_the_specific_date_time_and_store_the_output_in_specific_format/src/main/java/com/testsigma/addons/windowsadvanced/SubtractMinutesToDateTime.java`
around lines 90 - 103, The current heuristic in SubtractMinutesToDateTime uses
inputFormatString.contains("HH"|"mm"|"ss") and incorrectly sends mixed date-time
patterns (e.g., "yyyy-MM-dd HH:mm:ss") to LocalTime.parse; update the condition
to detect both date and time tokens: check for presence of any date-pattern
tokens (e.g., "y", "yyyy", "M", "MM", "d", "dd") AND any time-pattern tokens
("H","HH","m","mm","s","ss"); if both date AND time tokens are present, route to
LocalDateTime.parse(dateTimeString, inputFormatter) and use
newDateTime.minusMinutes(minutesToSubtract), otherwise if only time tokens use
LocalTime.parse(...) and newTime.minusMinutes(...), and if only date tokens
handle accordingly (or throw a clear error). Ensure you update the branches
around inputFormatter, LocalTime.parse, LocalDateTime.parse, newTime/newDateTime
and the returned formatted result.

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