{"record":{"id":"d73c19820f375fe9","repo":"grafana/k6","slug":"received-empty-load-tests-page-with-next-link","errorCode":null,"errorMessage":"received empty load tests page with next link","messagePattern":"received empty load tests page with next link","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloudapi/v6/api.go","lineNumber":131,"sourceCode":"\t\t\treturn nil, err\n\t\t}\n\n\t\tfor _, test := range res.Value {\n\t\t\ttests = append(tests, LoadTest{\n\t\t\t\tID:        test.Id,\n\t\t\t\tProjectID: test.ProjectId,\n\t\t\t\tName:      test.Name,\n\t\t\t\tCreated:   test.Created,\n\t\t\t\tUpdated:   test.Updated,\n\t\t\t})\n\t\t}\n\n\t\tif res.NextLink == nil || *res.NextLink == \"\" {\n\t\t\treturn tests, nil\n\t\t}\n\n\t\tif len(res.Value) == 0 {\n\t\t\treturn nil, errors.New(\"received empty load tests page with next link\")\n\t\t}\n\t\tskip += pageSize\n\t}\n}\n\nfunc (c *Client) listLoadTestsPage(\n\tctx context.Context, projectID int64, skip, top int32,\n) (*k6cloud.LoadTestListResponse, error) {\n\tres, hr, err := c.apiClient.LoadTestsAPI.\n\t\tProjectsLoadTestsRetrieve(c.authCtx(ctx), projectID).\n\t\tXStackId(c.stackID).\n\t\tSkip(skip).\n\t\tTop(top).\n\t\tExecute()\n\tdefer closeResponse(hr, &err)\n\n\tif err := CheckResponse(hr, err); err != nil {\n\t\treturn nil, err","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cloudapi/v6/api.go#L113-L149","documentation":"Thrown by the k6 Cloud v6 API client's load-test-list pagination loop when a page returned by ProjectsLoadTestsRetrieve has a non-empty nextLink but an empty value array. Like the projects variant, it guards against a server response that would otherwise cause either an infinite pagination loop or silently incomplete results.","triggerScenarios":"Calling Client.ListLoadTests for a projectID when the server returns 200 OK with Value=[] and a non-empty NextLink in the same LoadTestListResponse. The client-side inputs (projectID, skip/top paging) are well-formed; the response shape is what fails.","commonSituations":"Enumerating a project's load tests while tests are being created/deleted concurrently on the server, an API-side pagination bug, or a proxy rewriting the response. Usually transient and resolved by a retry.","solutions":["Retry the command; concurrent modifications on the server can momentarily produce empty pages","Confirm the project ID used actually belongs to your stack (K6_CLOUD_PROJECT_ID / --project-id)","Upgrade k6 so the vendored cloud API client matches the deployed API version","Capture the raw HTTP response with debug logging and escalate to Grafana support if persistent"],"exampleFix":"// before\nvar tests []k6cloud.LoadTest\nfor {\n    page, err := client.ListLoadTests(ctx, projectID)\n    if err != nil {\n        return err\n    }\n    tests = append(tests, page...)\n}\n\n// after: tolerate one empty-with-nextLink page by retrying the page once\ntests, err := client.ListLoadTests(ctx, projectID)\nif err != nil && strings.Contains(err.Error(), \"empty load tests page\") {\n    time.Sleep(2 * time.Second)\n    tests, err = client.ListLoadTests(ctx, projectID)\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"tests, err := client.ListLoadTests(ctx, projectID)\nif err != nil && strings.Contains(err.Error(), \"empty load tests page\") {\n    time.Sleep(2 * time.Second)\n    tests, err = client.ListLoadTests(ctx, projectID)\n}\nif err != nil {\n    return fmt.Errorf(\"listing load tests for project %d: %w\", projectID, err)\n}","preventionTips":["Avoid listing load tests while other automation concurrently creates/deletes tests in the same project","Retry once on pagination-anomaly errors before treating them as fatal","Keep k6 updated so client and server pagination contracts stay aligned"],"tags":["cloud","api","pagination","go","server-anomaly"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}