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

Revert k6/http.head to not taking body as second argument #2402

Merged
merged 5 commits into from
Mar 1, 2022

Conversation

mstoykov
Copy link
Collaborator

This has been the case forever until v0.36.0.

This has been the case forever until v0.36.0.
@mstoykov mstoykov linked an issue Feb 28, 2022 that may be closed by this pull request
@na--
Copy link
Member

na-- commented Feb 28, 2022

Ah, I probably messed it up with #2226 😞 Can you also add a test so we don't have the same regression again?

Also, I wonder if we shouldn't add a "known bugs" sections to the release notes and edit the v0.36.0 ones? This will be fixed in v0.37.0 in a couple of weeks, so probably no need to make a v0.36.1 point release, but it might still be useful to have it until then

@na-- na-- added this to the v0.37.0 milestone Feb 28, 2022
codebien
codebien previously approved these changes Feb 28, 2022
Copy link
Collaborator

@codebien codebien left a comment

Choose a reason for hiding this comment

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

Also, I wonder if we shouldn't add a "known bugs" sections to the release notes and edit the v0.36.0 ones?

+1 for this, if we are not going to release a patch.

@na--
Copy link
Member

na-- commented Feb 28, 2022

@mstoykov, can you add something like this to the bottom of /release notes/v0.36.0.md?

Known Bugs

#2226 introduced an unintended breaking change to http.head(). The signature in k6 v0.35.0 was http.head(url, [params]) and was inadvertently changed to http.head(url, [body], [params]) in v0.36.0. That change will be reverted in k6 v0.37.0, but until then, we suggest users use the stable http.request('HEAD', url, null, params) API for HTTP HEAD requests that need to specify custom parameters. Thanks, @grantyoung, for reporting the problem (#2401)!

We can edit the https://github.com/grafana/k6/releases/tag/v0.36.0 manually when we agree on the message

@@ -92,7 +92,10 @@ func (r *RootModule) NewModuleInstance(vu modules.VU) modules.Instance {
args = append([]goja.Value{goja.Undefined()}, args...) // sigh
return mi.defaultClient.Request(http.MethodGet, url, args...)
})
mustExport("head", mi.defaultClient.getMethodClosure(http.MethodHead))
mustExport("head", func(url goja.Value, args ...goja.Value) (*Response, error) {
args = append([]goja.Value{goja.Undefined()}, args...) // sigh
Copy link
Collaborator

@codebien codebien Feb 28, 2022

Choose a reason for hiding this comment

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

Suggested change
args = append([]goja.Value{goja.Undefined()}, args...) // sigh
// It avoid creating dedicated logic reusing the common Request method
// setting the body of the request to null.
args = append([]goja.Value{goja.Undefined()}, args...)

Sorry for seeing it just now, but if we want a comment there then I think we should use the opportunity for explaining why we are doing it.

Copy link
Member

Choose a reason for hiding this comment

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

hmm something like this will be better, I think:

Suggested change
args = append([]goja.Value{goja.Undefined()}, args...) // sigh
// http.head(url, params) doesn't have a body argument, so we add undefined
// as the third argument to http.request(method, url, body, params)
args = append([]goja.Value{goja.Undefined()}, args...) // sigh

Copy link
Member

Choose a reason for hiding this comment

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

+1 to this. I would rephrase it:

It avoids having to create some dedicated logic to reuse the common Request method

@oleiade
Copy link
Member

oleiade commented Feb 28, 2022

+1 to adding a "Known bugs" indeed. Moreover, as @codebien mentioned, we could probably release a "patch" release too?

oleiade
oleiade previously approved these changes Feb 28, 2022
Copy link
Member

@oleiade oleiade left a comment

Choose a reason for hiding this comment

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

👍🏻

Consider my comments as non-blocking.

@mstoykov mstoykov merged commit d18db70 into master Mar 1, 2022
@mstoykov mstoykov deleted the fixHttpHead branch March 1, 2022 08:44
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.

Issue with HEAD requests in 0.36.0?
4 participants