{"record":{"id":"93a6c7d10ed45082","repo":"grafana/k6","slug":"load-test-not-found","errorCode":null,"errorMessage":"load test not found","messagePattern":"load test not found","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloudapi/v6/errors.go","lineNumber":13,"sourceCode":"package cloudapi\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"strings\"\n\n\tk6cloud \"github.com/grafana/k6-cloud-openapi-client-go/k6\"\n)\n\nvar (\n\terrTestNotExists = errors.New(\"load test not found\")\n\terrUnknown       = errors.New(\"an error occurred communicating with k6 Cloud\")\n)\n\n// ResponseError represents an error cause by talking to the API\ntype ResponseError struct {\n\tResponse *http.Response        `json:\"-\"`\n\tAPIError k6cloud.ErrorApiModel `json:\"error\"`\n}\n\nfunc (e ResponseError) Error() string {\n\terr := e.APIError\n\tmsg := err.Message\n\n\tif err.Target.IsSet() {\n\t\tmsg += \" (target: '\" + *err.Target.Get() + \"')\"\n\t}\n\n\tdetails := make([]string, len(err.Details))","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cloudapi/v6/errors.go#L1-L31","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before: rely on create-or-find with a colliding name\n_, err := client.CreateOrFindLoadTest(ctx, \"my-test\", projectID, arc)\n\n// after: on the not-found path, fall back to creating under a distinct name\n_, err := client.CreateOrFindLoadTest(ctx, name, projectID, arc)\nif err != nil && strings.Contains(err.Error(), \"load test not found\") {\n    name = fmt.Sprintf(\"%s-%d\", name, time.Now().Unix())\n    _, err = client.CreateOrFindLoadTest(ctx, name, projectID, arc)\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"testID, err := client.CreateOrFindLoadTest(ctx, name, projectID, arc)\nif err != nil {\n    if strings.Contains(err.Error(), \"load test not found\") {\n        // 409 raced with a rename/delete: retry with a unique name\n        unique := fmt.Sprintf(\"%s-%d\", name, time.Now().UnixMilli())\n        testID, err = client.CreateOrFindLoadTest(ctx, unique, projectID, arc)\n    }\n    if err != nil {\n        return 0, err\n    }\n}","preventionTips":["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"],"tags":["cloud","api","race-condition","load-test","go"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}