{"record":{"id":"a00abe865cec9cb0","repo":"grafana/k6","slug":"failed-to-encode-project-list-w","errorCode":null,"errorMessage":"failed to encode project list: %w","messagePattern":"failed to encode project list: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/cloud_project_list.go","lineNumber":79,"sourceCode":"\n\tif len(projects) == 0 {\n\t\tprintToStdout(c.globalState, stackHeader+\n\t\t\t\"No projects found.\\n\"+\n\t\t\t\"To create a project, visit https://grafana.com/docs/grafana-cloud/testing/k6/projects-and-users/projects/\\n\")\n\t\treturn nil\n\t}\n\n\tprintToStdout(c.globalState, stackHeader+formatProjectTable(projects))\n\treturn nil\n}\n\nfunc (c *cmdCloudProjectList) outputJSON(projects []cloudapiv6.Project) error {\n\tbuf := &bytes.Buffer{}\n\tenc := json.NewEncoder(buf)\n\tenc.SetEscapeHTML(false)\n\tenc.SetIndent(\"\", \"  \")\n\tif err := enc.Encode(projects); err != nil {\n\t\treturn fmt.Errorf(\"failed to encode project list: %w\", err)\n\t}\n\n\tprintToStdout(c.globalState, buf.String())\n\treturn nil\n}\n\nfunc formatProjectTable(projects []cloudapiv6.Project) string {\n\tvar buf strings.Builder\n\tw := tabwriter.NewWriter(&buf, 0, 0, 3, ' ', 0)\n\t_, _ = fmt.Fprintln(w, \"ID\\tNAME\\tDEFAULT\")\n\tfor _, p := range projects {\n\t\tdef := \"no\"\n\t\tif p.IsDefault {\n\t\t\tdef = \"yes\"\n\t\t}\n\t\t_, _ = fmt.Fprintf(w, \"%d\\t%s\\t%s\\n\", p.ID, p.Name, def)\n\t}\n\t_ = w.Flush()","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/cmd/cloud_project_list.go#L61-L97","documentation":"Wrapped error in cmdCloudProjectList.outputJSON: encoding the fetched project list to JSON failed. As with the test list, this only happens if the data contains values the encoder cannot represent — effectively an internal fault.","triggerScenarios":"Thrown at internal/cmd/cloud_project_list.go:79 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the 'k6 cloud project list' command","Report as an internal bug if it reproduces consistently"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}