Ignore when calling http.get request with invalid character

Hi Guys, I have a question.
I would like to send an invalid rest request, for example: https:///v1/devices/%a

But when I run the test, following error are seen on k6 logs:
(* original domain url is redacted in the logs below)

INFO[0003] url:https://<domain url>/v1/devices/%a  source=console
ERRO[0003] GoError: parse "https://<domain url>/v1/devices/%!a(MISSING)": invalid URL escape "%!a(MISSING)"                                                                  running at github.com/loadimpact/k6/js/common.Bind.func1 (native)

Is there any way to ignore k6 url validation?

Usually, k6 will just show a warning for failed HTTP requests, unless you’ve explicitly enabled the throw option. Unfortunately, you’re hitting a known k6 bug that causes it to always throw an exception for invalid URLs: `throw` option not respected with malformed URLs · Issue #1502 · grafana/k6 · GitHub

We are hopefully going to fix this in k6 v0.30, since it’s too late to fit it into k6 v0.29.0 (slated for release next week). Until then, if making sure all URLs are invalid is impossible (if that is the case, can you elaborate why?), I’d suggest maybe using a wrapper around http.request() calls that either catches any exceptions or checks for URL validity itself and doesn’t execute requests for invalid URLs?

Hi Ned,
Thanks for your answer and information.

I don’t want to catch an exception in case of a request with invalid url, I would like to send the request as is to my server for behavior testing.

Unfortunately, k6 isn’t really capable of sending invalid HTTP requests to servers. We’ll have raw TCP support eventually, and you’d be able to do it that way, but the k6/http module depends on the standard Go net/http library, which has a lot of sanity checks for RFC compliance.