Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added check logic before splitting via comma separator #686

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kartikaysaxena
Copy link

fixes #555
Added check logic before split function

Signed-off-by: Kartikay <kartikay_2101ce32@iitp.ac.in>
@@ -53,6 +54,9 @@ func PrepareAWSSSMChaosByID(experimentsDetails *experimentTypes.ExperimentDetail
go lib.AbortWatcher(experimentsDetails, abort)

//get the instance id or list of instance ids
if strings.TrimSpace(experimentsDetails.EC2InstanceID) == "" {
return errors.Errorf("no instance id found for chaos injection")
}
instanceIDList := strings.Split(experimentsDetails.EC2InstanceID, ",")
if experimentsDetails.EC2InstanceID == "" || len(instanceIDList) == 0 {
Copy link
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>
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