Skip to content

Conversation

codebien
Copy link
Contributor

@codebien codebien commented Aug 29, 2025

What?

If the user is not logged in or didn't provide any TOKEN option via the available methods then it will fail with a nicer error hinting how to fix it.

If the token is provided but it is not valid then the error it is still delegated to the Cloud.

Why?

If the user forgot to log in or didn't know about the requirement now it is easier to understand and fix it.

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.

Checklist: Documentation (only for k6 maintainers and if relevant)

Please do not merge this PR until the following items are filled out.

  • I have added the correct milestone and labels to the PR.
  • I have updated the release notes: link
  • I have updated or added an issue to the k6-documentation: grafana/k6-docs#NUMBER if applicable
  • I have updated or added an issue to the TypeScript definitions: grafana/k6-DefinitelyTyped#NUMBER if applicable

Related PR(s)/Issue(s)

Closes #5077

@codebien codebien self-assigned this Aug 29, 2025
@codebien codebien force-pushed the cloud-login-error branch 3 times, most recently from 984c814 to d6a8512 Compare September 1, 2025 13:45
@codebien codebien marked this pull request as ready for review September 1, 2025 14:54
@codebien codebien requested a review from a team as a code owner September 1, 2025 14:54
@codebien codebien requested review from joanlopez and mstoykov and removed request for a team September 1, 2025 14:54
@codebien codebien added this to the v1.3.0 milestone Sep 1, 2025
"github.com/spf13/pflag"
)

// ErrUserUnauthenticated represents an authentication error when trying to use
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need to make this error public? 🤔 I'm wondering because I see it's used by no other package, and it's internal so other projects like extensions could not use it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, we don't. I've changed it, good catch!

Copy link
Contributor

@joanlopez joanlopez left a comment

Choose a reason for hiding this comment

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

Despite the few minor comments I left, it looks pretty well! 👍🏻

@codebien codebien requested a review from joanlopez September 1, 2025 15:49
@codebien codebien merged commit 6616971 into master Sep 2, 2025
37 checks passed
@codebien codebien deleted the cloud-login-error branch September 2, 2025 12:38
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.

Provide a more detailed error message when authentication to cloud fails

3 participants