grafana/k6 · error
load test not found
Error message
load test not found
What it means
errTestNotExists is returned by findTestByName when a load-test lookup filtered by exact name (Name(name).Top(1)) returns an empty list. It most commonly surfaces through CreateOrFindLoadTest: the create call got a 409 Conflict (name already exists), but the follow-up name lookup found nothing.
Source
Thrown at internal/cloudapi/v6/errors.go:13
package cloudapi
import (
"errors"
"fmt"
"net/http"
"strings"
k6cloud "github.com/grafana/k6-cloud-openapi-client-go/k6"
)
var (
errTestNotExists = errors.New("load test not found")
errUnknown = errors.New("an error occurred communicating with k6 Cloud")
)
// ResponseError represents an error cause by talking to the API
type ResponseError struct {
Response *http.Response `json:"-"`
APIError k6cloud.ErrorApiModel `json:"error"`
}
func (e ResponseError) Error() string {
err := e.APIError
msg := err.Message
if err.Target.IsSet() {
msg += " (target: '" + *err.Target.Get() + "')"
}
details := make([]string, len(err.Details))View on GitHub (pinned to 93accf6570)
Solutions
- Retry the command; races between the 409 and the lookup are usually transient
- Verify K6_CLOUD_PROJECT_ID / --project-id matches the project that actually contains the named test
- Check the test name in the Grafana Cloud UI for case or whitespace mismatches
- Run with a unique test name (K6_CLOUD_NAME or --name) to sidestep the conflict path entirely
Example fix
// before: rely on create-or-find with a colliding name
_, err := client.CreateOrFindLoadTest(ctx, "my-test", projectID, arc)
// after: on the not-found path, fall back to creating under a distinct name
_, err := client.CreateOrFindLoadTest(ctx, name, projectID, arc)
if err != nil && strings.Contains(err.Error(), "load test not found") {
name = fmt.Sprintf("%s-%d", name, time.Now().Unix())
_, err = client.CreateOrFindLoadTest(ctx, name, projectID, arc)
} Defensive patterns
Strategy: fallback
Try / catch
testID, err := client.CreateOrFindLoadTest(ctx, name, projectID, arc)
if err != nil {
if strings.Contains(err.Error(), "load test not found") {
// 409 raced with a rename/delete: retry with a unique name
unique := fmt.Sprintf("%s-%d", name, time.Now().UnixMilli())
testID, err = client.CreateOrFindLoadTest(ctx, unique, projectID, arc)
}
if err != nil {
return 0, err
}
} Prevention
- Give CI pipelines distinct test names (timestamp/job-id suffix) to avoid 409-rename races
- Pin K6_CLOUD_PROJECT_ID so create and lookup always hit the same project
- Avoid running two `k6 cloud run` invocations with the same name against one project concurrently
When it happens
Trigger: CreateOrFindLoadTest -> 409 on LoadTestsCreate -> findTestByName lists with a name filter and gets zero results. Also reachable directly by anything calling findTestByName. Happens when the conflicting test is deleted between the two calls, the name filter does not match exactly (case/whitespace), or the listing is scoped to a different project than the conflict.
Common situations: Two concurrent `k6 cloud run` invocations using the same test name against the same project; a test renamed or deleted in the Grafana Cloud UI mid-flight; K6_CLOUD_PROJECT_ID pointing at a different project than the one holding the name conflict.
Related errors
- received empty projects page with next link
- received empty load tests page with next link
- unexpected nil response from CreateOrFindLoadTest
- stack URL is required to validate token
- could not create the cloud test run: %w
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/93a6c7d10ed45082.
Report an issue: GitHub.