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

http.batch invalid method error #295

artych opened this Issue Aug 18, 2017 · 0 comments


None yet
1 participant

artych commented Aug 18, 2017

Running the script:

import { group } from 'k6';
import http from 'k6/http';

export default function() {

  group("page_1", function() {
      url: "",
      method: "GET"

I get error:

ERRO[0032] GoError: net/http: invalid method "HTTPS://LOADIMPACT.COM/"

I wonder if arguments can be mixed up, and yes, after swapping the properties like:

      method: "GET",
      url: ""

it works good.

borjacampina added a commit to borjacampina/k6 that referenced this issue Aug 19, 2017

fixes issue with obj form requests in batch mode
closes loadimpact#295

Maybe this is not the perfect solution. I hope it helps to solve it as reference.

In batch mode (shorthand and object form requests), k6 obtains the method and url parameters given their position (0=method, 1=url) only, so when we use object form requests only uses their position and the object keys (url and method) are ignored. That means, for a request object like "{url:"", method:"get"}", is misinterpreted as method parameter.

For shorthand requests, obj is a []interface{} type, their obj.Keys() are "0", "1"...
For object form requests, obj is a map[string]interface{} type, their obj.Keys() are "url", "method"...

This PR allows us to use "0" as an alias for "method" and "1" for "url" in object form requests: "{0:"", 1:"get"}".
We can avoid this issue: if the obj object is a map type (v.ExportType().Kind().String() == "map" ??) we only should handle "method" and "url" keys. I can include it if it's important.

@liclac liclac closed this in #297 Oct 5, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment