{"record":{"id":"17b6b730204ffdf2","repo":"grafana/k6","slug":"handlesummary-should-return-a-map-with-string-ke","errorCode":null,"errorMessage":"handleSummary() should return a map with string keys","messagePattern":"handleSummary\\(\\) should return a map with string keys","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/summary.go","lineNumber":216,"sourceCode":"\t}\n\n\treturn map[string]any{\n\t\t\"name\":   group.Name,\n\t\t\"path\":   group.Path,\n\t\t\"id\":     group.ID,\n\t\t\"groups\": subGroups,\n\t\t\"checks\": checks,\n\t}\n}\n\nfunc getSummaryResult(rawResult sobek.Value) (map[string]io.Reader, error) {\n\tif common.IsNullish(rawResult) {\n\t\treturn nil, nil //nolint:nilnil // this is actually valid result in this case\n\t}\n\n\trawResultMap, ok := rawResult.Export().(map[string]any)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"handleSummary() should return a map with string keys\")\n\t}\n\n\tresults := make(map[string]io.Reader, len(rawResultMap))\n\tfor path, val := range rawResultMap {\n\t\treaderVal, err := common.GetReader(val)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error handling summary object %s: %w\", path, err)\n\t\t}\n\t\tresults[path] = readerVal\n\t}\n\n\treturn results, nil\n}\n","sourceCodeStart":198,"sourceCodeEnd":230,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/summary.go#L198-L230","documentation":"A user-defined handleSummary callback ran successfully but its return value, after export to Go, is not a map[string]any. k6 expects a plain object whose keys are output destinations (file paths, 'stdout', 'stderr', or https:// URLs) and whose values are summary text or data. Returning an array, a string, a class instance, or an array of pairs fails this type assertion.","triggerScenarios":"Thrown at internal/js/summary.go:216 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Return a plain object literal, e.g. { 'stdout': textSummary(data), 'file.json': JSON.stringify(data) }","Do not return arrays, Maps, or constructor instances; use plain object literals so they export as map[string]any","Returning undefined/null is also accepted and produces no custom output"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}