Skip to content

Commit

Permalink
grafana#1289: Moved Init context validation before multiple array val…
Browse files Browse the repository at this point in the history
…idation
  • Loading branch information
vanshaj committed Jul 5, 2022
1 parent 5ce2f64 commit 9744915
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions js/modules/k6/http/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,18 +438,18 @@ func (c *Client) prepareBatchObject(requests map[string]interface{}) (
// Batch makes multiple simultaneous HTTP requests. The provideds reqsV should be an array of request
// objects. Batch returns an array of responses and/or error
func (c *Client) Batch(reqsValues ...goja.Value) (interface{}, error) {
state := c.moduleInstance.vu.State()
if state == nil {
return nil, ErrBatchForbiddenInInitContext
}

if len(reqsValues) == 0 {
return nil, fmt.Errorf("no argument was provided to http.batch()")
} else if len(reqsValues) > 1 {
} else if len(reqsValues) > 1 { // Validation for http.batch(["https://validurl"],["https://validurl"])
return nil, fmt.Errorf("http.batch() must have only one single array as an argument")
}

reqsV := reqsValues[0]
state := c.moduleInstance.vu.State()
if state == nil {
return nil, ErrBatchForbiddenInInitContext
}

var (
err error
batchReqs []httpext.BatchParsedHTTPRequest
Expand Down

0 comments on commit 9744915

Please sign in to comment.