grafana/k6 · error
creating v6 client
Error message
creating v6 client: %w
What it means
Returned by provisioning.NewClient (internal/cloudapi/provisioning/client.go:54) when the embedded v6.NewClient call fails. Reading internal/cloudapi/v6/client.go:29-32, the v6 constructor's only failure mode is an empty token — but provisioning.NewClient has already rejected empty tokens at client.go:47 before this call, so with current code this error is effectively unreachable. Seeing it in the wild implies version drift (the two checks disagree) or a patched/derived build.
Solutions
- Confirm you are running a consistent k6 build (no partial vendoring/replace directives mixing versions) — 'go version -m ./k6' or rebuild from clean checkout.
- If you maintain a fork that added new failure modes to v6.NewClient, either handle them here or keep the token guard and v6 contract in sync.
- For upstream builds, treat occurrence as a bug: report the k6 version and stack trace to the k6 issue tracker.
Defensive patterns
Strategy: try-catch
Validate before calling
// Guard the inputs this wrapper is known to need, since its own failure is defensive-only.
if token == "" {
return errors.New("empty cloud token")
}
if _, err := v6.NewClient(logger, token, host, version, timeout); err != nil {
return fmt.Errorf("v6 client rejected configuration: %w", err)
} Try / catch
if _, err := provisioning.NewClient(logger, token, host, version, stackID, timeout); err != nil {
if strings.Contains(err.Error(), "creating v6 client") {
// effectively unreachable upstream — indicates version drift or a fork; realign versions
return fmt.Errorf("k6 build inconsistency (provisioning vs v6 client contract): %w", err)
}
} Prevention
- Build k6 from a single consistent version; avoid mixing vendored/replace directives across internal/cloudapi packages.
- If forking, keep provisioning.NewClient's guards and v6.NewClient's failure modes in sync.
- Report upstream occurrences with the exact k6 version.
When it happens
Trigger: v6.NewClient returning an error, which per its source happens only for token == ""; reachable only if the empty-token guard above was removed/altered or the embedded v6 package's failure modes changed between versions.
Common situations: Mixing k6 versions via replace directives or vendored forks where client.go and v6/client.go diverge; downstream forks adding new validation to v6.NewClient without updating provisioning.
Related errors
AI-assisted analysis of grafana/k6@8d06114777 (2026-08-18).
Data as JSON: /api/errors/0f2c5b0f405791f1.
Report an issue: GitHub.
Appendix: source
Thrown at internal/cloudapi/provisioning/client.go:54
// NewClient returns a new provisioning Client. It internally constructs
// both a k6cloud.APIClient (for provisioning endpoints) and a v6.Client
// (for v6 operations like FetchTest). The stackID identifies the
// Grafana Cloud stack and is required for the stack-scoped requests.
func NewClient(
logger logrus.FieldLogger,
token, host, version string,
stackID int64,
timeout time.Duration,
) (*Client, error) {
if token == "" {
return nil, fmt.Errorf("token is required to create provisioning API client")
}
cfg := clientcfg.New(host, version, "k6 Cloud API (provisioning).", timeout)
v6c, err := v6.NewClient(logger, token, host, version, timeout)
if err != nil {
return nil, fmt.Errorf("creating v6 client: %w", err)
}
c := &Client{
apiClient: k6cloud.NewAPIClient(cfg),
v6Client: v6c,
token: token,
stackID: stackID,
host: host,
version: version,
logger: logger,
}
// Propagate the stack ID to the embedded v6 client. v6.SetStackID
// validates that it fits the int32 the SDK's X-Stack-Id requires —
// that is the single place the int32 boundary is enforced.
if err := c.v6Client.SetStackID(stackID); err != nil {
return nil, err
}
// The provisioning endpoints carry the stack ID as a decimal-stringView on GitHub (pinned to 8d06114777)