fix: normalize cloud login stack URLs with trailing slashes#6087
Open
oleiade wants to merge 7 commits into
Open
fix: normalize cloud login stack URLs with trailing slashes#6087oleiade wants to merge 7 commits into
oleiade wants to merge 7 commits into
Conversation
Trim trailing `/` characters from `k6 cloud login` stack inputs before validating them with Grafana Cloud. A trailing slash was sent to the Cloud auth API as part of `X-Stack-Url`, which made an otherwise valid stack such as `https://my-team.grafana.net/` fail authentication as not found. Adds unit coverage for stack URL normalization and command coverage for login with a trailing-slash stack URL. Supersedes #5904 (original fix by @cyphercodes), which is blocked on an unsigned CLA. Fixes #5894
4 tasks
ankur22
previously approved these changes
Jun 16, 2026
mstoykov
reviewed
Jun 16, 2026
mstoykov
reviewed
Jun 18, 2026
mstoykov
reviewed
Jun 18, 2026
Co-authored-by: Mihail Stoykov <312246+mstoykov@users.noreply.github.com>
mstoykov
approved these changes
Jun 19, 2026
ankur22
previously approved these changes
Jun 19, 2026
mstoykov
requested changes
Jun 19, 2026
mstoykov
left a comment
Contributor
There was a problem hiding this comment.
linter and some tests are failing :(
A review suggestion switched normalizeStackURL to url.Parse but returned u.String(), which keeps the path and so preserved the very trailing slash the function exists to strip (https://team.grafana.net/ stayed https://team.grafana.net/). Rebuild the URL from scheme and host only, dropping any path including one or more trailing slashes. Trim trailing slashes on the slug branch as well, since that trim was dropped from stripGrafanaNetSuffix. This also corrects the misindented closing brace that failed the gofmt lint check.
Contributor
Author
|
Add to revert to instantiating a url again to make the tests pass. That allows cleaning up whatever else is the URL to only keep the core stack URL 🙇🏻 |
ankur22
approved these changes
Jun 19, 2026
szkiba
approved these changes
Jun 22, 2026
mstoykov
approved these changes
Jun 26, 2026
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Supersedes #5904 (original fix by @cyphercodes), which is blocked on an unsigned CLA.
Fixes #5894
Why?
Trim trailing
/characters fromk6 cloud loginstack inputs before validating them with Grafana Cloud. A trailing slash was sent to the Cloud auth API as part ofX-Stack-Url, which made an otherwise valid stack such ashttps://my-team.grafana.net/fail authentication as not found.Adds unit coverage for stack URL normalization and command coverage for login with a trailing-slash stack URL.
Checklist
make check) and all pass.Checklist: Documentation (only for k6 maintainers and if relevant)
Please do not merge this PR until the following items are filled out.
Related PR(s)/Issue(s)
closes #5904
fixes #5894