grafana/k6 · error
creating v6 client: %w
Error message
creating v6 client: %w
What it means
provisioning.NewClient (internal/cloudapi/provisioning/client.go:54) wraps the failure of the embedded v6.NewClient. Today v6.NewClient only fails on an empty token, which the caller has already guarded, so this wrapper is defensive and effectively unreachable; if it ever fires, the wrapped error (%w) carries the real cause.
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 93accf6570)
Solutions
- Inspect the wrapped error with errors.Unwrap / %w chaining to find the real cause
- Check the k6 version and the v6.NewClient guard in that version
- If adding new validation to v6.NewClient, mirror it (or pre-validate) in provisioning.NewClient to keep the message actionable
Defensive patterns
Strategy: try-catch
Type guard
func isV6ConstructionFailure(err error) bool {
return err != nil && strings.Contains(err.Error(), "creating v6 client")
} Try / catch
client, err := provisioning.NewClient(...)
if err != nil {
if inner := errors.Unwrap(err); inner != nil {
log.Printf("v6 client failure cause: %v", inner)
}
return err
} Prevention
- Always unwrap chained construction errors before diagnosing
- When adding validation to one constructor, mirror it in wrappers to keep messages actionable
When it happens
Trigger: v6.NewClient returning an error during provisioning client construction — only possible if the two guards diverge in a future version (e.g. v6 starts validating host or token format).
Common situations: Version drift after refactoring one client's constructor but not the other; effectively never seen in the wild today.
Related errors
- token is required to create provisioning API client
- token is required to create cloud API client
- stack URL is required to validate token
- Run `k6 cloud login` to authenticate, or check the docs for
- access token not configured
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/0f2c5b0f405791f1.
Report an issue: GitHub.