Skip to content

Warn when http.get or http.head receive extra arguments - #5815

Merged
codebien merged 4 commits into
grafana:masterfrom
moko-poi:warn-http-get-head-extra-args
Apr 15, 2026
Merged

codebien merged 4 commits into
grafana:masterfrom
moko-poi:warn-http-get-head-extra-args

Conversation

@moko-poi

@moko-poi moko-poi commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

What?

Emit a warning log when http.get or http.head are called with more than 2 arguments (url + params).

Why?

http.get and http.head only accept (url, params), unlike http.post and other HTTP methods which accept (url, body, params). Users commonly write
http.get(url, null, params) expecting the same 3-argument signature, which silently ignores the extra params. This warning helps users notice the mistake.

Checklist

  • I have performed a self-review of my code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests for my changes.
  • I have run linter and tests locally (make check) and all pass.

Related PR(s)/Issue(s)

Closes #2823

@moko-poi
moko-poi requested a review from a team as a code owner April 8, 2026 03:46
@moko-poi
moko-poi requested review from joanlopez and szkiba and removed request for a team April 8, 2026 03:46

@codebien codebien left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey @moko-poi ๐Ÿ‘‹ Thanks for this contribution ๐ŸŽ‰

It seems the linter is complaining, can you address that issue, please? The rest of the code sounds good to me, thanks ๐Ÿ™‡

@moko-poi

moko-poi commented Apr 8, 2026

Copy link
Copy Markdown
Contributor Author

@codebien Fixed the lll lint errors by splitting the long Warnf calls in http.get/http.head across multiple lines. PTAL ๐Ÿ™

@moko-poi
moko-poi requested a review from codebien April 8, 2026 13:03
@moko-poi
moko-poi temporarily deployed to azure-trusted-signing April 8, 2026 13:31 — with GitHub Actions Inactive
@moko-poi
moko-poi temporarily deployed to azure-trusted-signing April 8, 2026 13:33 — with GitHub Actions Inactive
Avoids flaky context deadline exceeded failures in
TestComplicatedFileImportsForGRPC on Windows CI.
Comment thread internal/js/runner_test.go Outdated
require.Empty(t, options.Validate())

ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)

@codebien codebien Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It doesn't sound the good approach, we should find a way to speed-up things here or even better make the test not time-dependent.

However, any change to address it, should live in a dedicated pull request. For this specific pull request we can just retry.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@codebien Thanks for the feedback! You're right, I've reverted the timeout change. I'll retry the CI instead. If the flaky test needs a proper fix, I'll address it in a separate PR.

@moko-poi
moko-poi requested a review from codebien April 9, 2026 03:13
@moko-poi
moko-poi temporarily deployed to azure-trusted-signing April 9, 2026 10:04 — with GitHub Actions Inactive
@moko-poi
moko-poi temporarily deployed to azure-trusted-signing April 9, 2026 10:05 — with GitHub Actions Inactive
@codebien codebien added this to the v2.0.0 milestone Apr 10, 2026
@codebien
codebien merged commit 6940471 into grafana:master Apr 15, 2026
53 checks passed
@mstoykov mstoykov modified the milestones: v2.0.0, v2.0.0-rc1 Apr 22, 2026
@joanlopez joanlopez mentioned this pull request Apr 27, 2026
3 of 8 tasks
inancgumus pushed a commit that referenced this pull request May 15, 2026
Warn when http.get or http.head are invoked with extra unexpected arguments

Co-authored-by: Shun Takahashi <mokopoi44@gmail.com>

This branch was previously deployed

1 inactive deployment
azure-trusted-signing โ€” 50a5feb2 Deployed Apr 9, 2026 by moko-poi via sign-packages #8893
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.

Display a warning when using http.get and http.head with more than 2 arguments

4 participants