{"record":{"id":"908c4969c8eb2dfb","repo":"grafana/k6","slug":"failed-to-encode-test-list-w","errorCode":null,"errorMessage":"failed to encode test list: %w","messagePattern":"failed to encode test list: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/cloud_loadtest_list.go","lineNumber":121,"sourceCode":"\tif id == 0 {\n\t\treturn 0, errNoProjectConfigured\n\t}\n\n\treturn id, nil\n}\n\nfunc (c *cmdCloudTestList) outputJSON(tests []v6cloudapi.LoadTest) error {\n\t// If tests is nil, initialize it to an empty slice to avoid encoding it as null.\n\tif tests == nil {\n\t\ttests = []v6cloudapi.LoadTest{}\n\t}\n\n\tbuf := &bytes.Buffer{}\n\tenc := json.NewEncoder(buf)\n\tenc.SetEscapeHTML(false)\n\tenc.SetIndent(\"\", \"  \")\n\tif err := enc.Encode(tests); err != nil {\n\t\treturn fmt.Errorf(\"failed to encode test list: %w\", err)\n\t}\n\n\tprintToStdout(c.globalState, buf.String())\n\treturn nil\n}\n\nfunc formatLoadTestTable(tests []v6cloudapi.LoadTest) string {\n\tconst dateFormat = \"2006-01-02 15:04\"\n\n\tvar buf strings.Builder\n\tw := tabwriter.NewWriter(&buf, 0, 0, 3, ' ', 0)\n\t_, _ = fmt.Fprintln(w, \"ID\\tNAME\\tCREATED\\tUPDATED\")\n\tfor _, t := range tests {\n\t\t_, _ = fmt.Fprintf(w, \"%d\\t%s\\t%s\\t%s\\n\",\n\t\t\tt.ID, t.Name,\n\t\t\tt.Created.UTC().Format(dateFormat),\n\t\t\tt.Updated.UTC().Format(dateFormat),\n\t\t)","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/cmd/cloud_loadtest_list.go#L103-L139","documentation":"Wrapped error in cmdCloudTestList.outputJSON: encoding the fetched cloud load test list (guaranteed non-nil) to JSON failed. Encoding failures are practically impossible for this data shape and indicate a serializer-level fault rather than bad input.","triggerScenarios":"Thrown at internal/cmd/cloud_loadtest_list.go:121 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat as a k6 internal bug and report it if reproducible","Retry the command; transient corruption of the API response data is unlikely but possible"],"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"}