grafana/k6 · error
default stack configured but the default project ID is not…
Error message
default stack configured but the default project ID is not available - please run `k6 cloud login` to refresh your configuration
What it means
resolveProjectID found a configured stack (StackID valid and non-zero) but no usable default project: DefaultProjectID is unset or ≤ 0, so it cannot infer which project the test belongs to. The config in this state is stale — the stack block exists without the default-project field that a completed `k6 cloud login` writes — and the error tells you to refresh the configuration rather than guess.
Solutions
- Run `k6 cloud login` again — it rewrites the config including the default project
- Or bypass inference: pass --project-id <id> on the command
- Or set K6_CLOUD_PROJECT_ID in the environment
- Find the numeric project ID in the Grafana Cloud k6 app URL/project picker if unsure
Example fix
# before k6 cloud run script.js # ERR: default stack configured but the default project ID is not available # after k6 cloud login # refreshes token, stack, and default project k6 cloud run script.js # or: k6 cloud run --project-id 123 script.js
Defensive patterns
Strategy: validation
Validate before calling
if conf.StackID.Valid && conf.StackID.Int64 != 0 &&
(!conf.DefaultProjectID.Valid || conf.DefaultProjectID.Int64 <= 0) {
return fmt.Errorf("stale login config: default project missing; re-run `k6 cloud login` or pass --project-id")
} Prevention
- Re-run `k6 cloud login` after every k6 upgrade that touches cloud config
- Pass --project-id explicitly in CI so inference never matters
- Treat missing-but-expected config fields as stale state, not defaults
When it happens
Trigger: Config file written by an older k6 version or by hand (stack_id present, default_project_id missing), a partially updated login, or programmatic config assembly that copies StackID but not DefaultProjectID. Only reached when --project-id and K6_CLOUD_PROJECT_ID are absent and ProjectID in config is unset/0.
Common situations: Upgrading k6 across versions where the login config schema gained default_project_id, sharing a config file between machines with different logins, or `k6 cloud login` interrupted mid-write.
Related errors
- : .\n
- create or find load test
- invalid stack URL
- no project specified. Use --project-id, set…
- an error occurred communicating with k6 Cloud
AI-assisted analysis of grafana/k6@94169daab2 (2026-08-18).
Data as JSON: /api/errors/606ef3d16f1f21f2.
Report an issue: GitHub.
Appendix: source
Thrown at internal/cmd/cloud.go:577
func resolveDefaultProjectID(
gs *state.GlobalState,
cloudConfig *cloudapi.Config,
) (int64, error) {
// Priority: projectID -> default stack from config
if cloudConfig.ProjectID.Valid && cloudConfig.ProjectID.Int64 > 0 {
return cloudConfig.ProjectID.Int64, nil
}
if cloudConfig.StackID.Valid && cloudConfig.StackID.Int64 != 0 {
if cloudConfig.DefaultProjectID.Valid && cloudConfig.DefaultProjectID.Int64 > 0 {
stackName := cloudConfig.StackURL.String
if !cloudConfig.StackURL.Valid {
stackName = fmt.Sprintf("stack-%d", cloudConfig.StackID.Int64)
}
gs.Logger.Warnf("No projectID specified, using default project of the %s stack\n", stackName)
return cloudConfig.DefaultProjectID.Int64, nil
}
return 0, fmt.Errorf(
"default stack configured but the default project ID is not available - " +
"please run `k6 cloud login` to refresh your configuration")
}
// Return 0 to let the backend pick the project (old behavior)
return 0, nil
}
func resolveAndSetProjectID(
gs *state.GlobalState,
cloudConfig *cloudapi.Config,
tmpCloudConfig map[string]any,
arc *lib.Archive,
) error {
projectID, err := resolveDefaultProjectID(gs, cloudConfig)
if err != nil {
return err
}View on GitHub (pinned to 94169daab2)