Skip to content

added check logic before splitting via comma separator#686

Open
kartikaysaxena wants to merge 2 commits intolitmuschaos:masterfrom
kartikaysaxena:fix-comma-separator-logic
Open

added check logic before splitting via comma separator#686
kartikaysaxena wants to merge 2 commits intolitmuschaos:masterfrom
kartikaysaxena:fix-comma-separator-logic

Conversation

@kartikaysaxena
Copy link
Copy Markdown

fixes #555
Added check logic before split function

Signed-off-by: Kartikay <kartikay_2101ce32@iitp.ac.in>
return errors.Errorf("no instance id found for chaos injection")
}
instanceIDList := strings.Split(experimentsDetails.EC2InstanceID, ",")
if experimentsDetails.EC2InstanceID == "" || len(instanceIDList) == 0 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This check is redundant now, please check in other places too. Also, we should handle an edge case where the input contains only one or more commas. For example, strings.Split of "," will give us a string slice containing two whitespaces.

Signed-off-by: Kartikay <kartikay_2101ce32@iitp.ac.in>
xnaveenx added a commit to xnaveenx/litmus-go that referenced this pull request Dec 23, 2025
…uschaos#555)

This supersedes stale PRs litmuschaos#564 and litmuschaos#686 by introducing a centralized, tested utility.

- Added SplitList function to pkg/utils/stringutils to safely handle comma-separated strings
- Added unit tests covering edge cases (empty strings, trailing commas, spaces, only commas)
- Verified fix for issue where empty input returned slice of length 1
xnaveenx added a commit to xnaveenx/litmus-go that referenced this pull request Dec 23, 2025
…uschaos#555)

This supersedes stale PRs litmuschaos#564 and litmuschaos#686 by introducing a centralized, tested utility.

- Added SplitList function to pkg/utils/stringutils to safely handle comma-separated strings
- Added unit tests covering edge cases (empty strings, trailing commas, spaces, only commas)
- Verified fix for issue where empty input returned slice of length 1

Signed-off-by: xnaveen <naveen010210@gmail.com>
xnaveenx added a commit to xnaveenx/litmus-go that referenced this pull request Jan 7, 2026
…uschaos#555)

This supersedes stale PRs litmuschaos#564 and litmuschaos#686 by introducing a centralized, tested utility.

- Added SplitList function to pkg/utils/stringutils to safely handle comma-separated strings
- Added unit tests covering edge cases (empty strings, trailing commas, spaces, only commas)
- Verified fix for issue where empty input returned slice of length 1

Signed-off-by: xnaveen <naveen010210@gmail.com>
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.

Logic for splitting comma-separated inputs need to be fixed

2 participants