{"record":{"id":"87065c34cc9e7610","repo":"grafana/k6","slug":"received-empty-projects-page-with-next-link","errorCode":null,"errorMessage":"received empty projects page with next link","messagePattern":"received empty projects page with next link","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloudapi/v6/api.go","lineNumber":76,"sourceCode":"\t\tres, err := c.listProjectsPage(ctx, skip, pageSize)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tfor _, project := range res.Value {\n\t\t\tprojects = append(projects, Project{\n\t\t\t\tID:        project.Id,\n\t\t\t\tName:      project.Name,\n\t\t\t\tIsDefault: project.IsDefault,\n\t\t\t})\n\t\t}\n\n\t\tif res.NextLink == nil || *res.NextLink == \"\" {\n\t\t\treturn projects, nil\n\t\t}\n\n\t\tif len(res.Value) == 0 {\n\t\t\treturn nil, errors.New(\"received empty projects page with next link\")\n\t\t}\n\t\tskip += pageSize\n\t}\n}\n\nfunc (c *Client) listProjectsPage(\n\tctx context.Context, skip, top int32,\n) (*k6cloud.ProjectListResponse, error) {\n\tres, hr, err := c.apiClient.ProjectsAPI.\n\t\tProjectsList(c.authCtx(ctx)).\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":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/cloudapi/v6/api.go#L58-L94","documentation":"Thrown by the k6 v6 cloud API client's ListProjects when a paginated ProjectsList response returns zero items (res.Value empty) but still carries a non-empty NextLink. The client treats 'next link but empty page' as a broken pagination contract: continuing would either loop forever or silently return an incomplete project list, so it aborts. It surfaces through `k6 cloud project list`.","triggerScenarios":"Calling Client.ListProjects (the code behind `k6 cloud project list`) when the stack has more than 1000 projects (the fixed pageSize) and the service returns a page with an empty Value array while NextLink is set; also triggered by a mismatched k6-cloud-openapi-client-go version or a proxy/gateway that mangles the JSON list response.","commonSituations":"Large organizations with 1000+ projects in one Grafana Cloud stack; corporate proxies rewriting response bodies; transient backend bugs during heavy load; running an old k6 binary against an updated cloud API contract.","solutions":["Retry the command once or twice — transient server-side pagination glitches usually clear","Update k6 to the latest version so the bundled cloud API client matches the current contract","Cross-check in the Grafana Cloud UI that the stack actually has projects and note whether it exceeds 1000","Bypass intermediaries (VPN/proxy) or check their response rewriting, then retry","If reproducible, capture `k6 cloud project list` with verbose logging and report it as a k6 or Grafana Cloud bug"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep k6 updated so the embedded cloud API client tracks the current list contract","In CI, wrap `k6 cloud project list` in a bounded retry (1-2 attempts) for transient pagination glitches","Keep project counts reviewable — archive unused projects so pagination edge cases stay unlikely"],"tags":["k6","cloud-api","pagination","project-list","grafana-cloud"],"backgroundTag":"pagination-inconsistency","analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}