{"record":{"id":"e886bda0c1a08345","repo":"grafana/k6","slug":"unexpected-error-while-generating-the-summary-w","errorCode":null,"errorMessage":"unexpected error while generating the summary: %w","messagePattern":"unexpected error while generating the summary: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/runner.go","lineNumber":424,"sourceCode":"\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unexpected error while getting the summary wrapper: %w\", err)\n\t}\n\thandleSummaryWrapper, ok := sobek.AssertFunction(handleSummaryWrapperRaw)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected error did not get a callable summary wrapper\")\n\t}\n\n\twrapperArgs := prepareHandleWrapperArgs(\n\t\tvu, noColor, enableColors, newMachineReadableSummary, callbackResult, handleSummaryData, summaryData,\n\t)\n\trawResult, _, _, err := vu.runFn(summaryCtx, false, handleSummaryWrapper, nil, wrapperArgs...)\n\n\tif deadlineError := r.checkDeadline(summaryCtx, consts.HandleSummaryFn, rawResult, err); deadlineError != nil {\n\t\treturn nil, deadlineError\n\t}\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unexpected error while generating the summary: %w\", err)\n\t}\n\n\treturn getSummaryResult(rawResult)\n}\n\nfunc prepareHandleSummaryCall(\n\tr *Runner,\n\trt *sobek.Runtime,\n\tlegacy *lib.LegacySummary,\n\ts *summary.Summary,\n\tmeta summary.Meta,\n) (bool, bool, bool, string, sobek.Value, sobek.Value, error) {\n\tvar (\n\t\tnoColor                   bool\n\t\tenableColors              bool\n\t\tnewMachineReadableSummary bool\n\t\tsummaryCode               string\n\t\tsummaryData               sobek.Value","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/runner.go#L406-L442","documentation":"The handleSummary wrapper function was invoked but its execution returned an error. Unlike the wrapper-compilation error, this fires while the summary code actually runs, so the cause is usually the user-supplied handleSummary callback throwing (e.g. accessing a missing data field) or an error inside the bundled summary rendering logic.","triggerScenarios":"Thrown at internal/js/runner.go:424 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wrap the body of handleSummary in try/catch and log the caught error to stderr to isolate the failing line","Verify the data argument structure (data.metrics, data.groups, data.checks, data.options) before accessing nested fields","Return well-formed entries: a map of filename/URL path to string or object payload"],"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":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}