{"record":{"id":"fac45764e044e139","repo":"grafana/k6","slug":"unexpected-data-after-the-json-object","errorCode":null,"errorMessage":"unexpected data after the JSON object","messagePattern":"unexpected data after the JSON object","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/helpers.go","lineNumber":23,"sourceCode":"\t\"encoding/json\"\n\t\"fmt\"\n\t\"strings\"\n\t\"time\"\n)\n\n// StrictJSONUnmarshal decodes a JSON in a strict manner, emitting an error if there\n// are unknown fields or unexpected data\nfunc StrictJSONUnmarshal(data []byte, v any) error {\n\tdec := json.NewDecoder(bytes.NewReader(data))\n\tdec.DisallowUnknownFields()\n\tdec.UseNumber()\n\n\tif err := dec.Decode(&v); err != nil {\n\t\treturn err\n\t}\n\tif dec.More() {\n\t\t// TODO: use a custom error?\n\t\treturn fmt.Errorf(\"unexpected data after the JSON object\")\n\t}\n\treturn nil\n}\n\n// GetMaxPlannedVUs returns the maximum number of planned VUs at any stage of\n// the execution plan.\nfunc GetMaxPlannedVUs(steps []ExecutionStep) (result uint64) {\n\tfor _, s := range steps {\n\t\tstepMaxPlannedVUs := s.PlannedVUs\n\t\tif stepMaxPlannedVUs > result {\n\t\t\tresult = stepMaxPlannedVUs\n\t\t}\n\t}\n\treturn result\n}\n\n// GetMaxPossibleVUs returns the maximum number of planned + unplanned (i.e.\n// initialized mid-test) VUs at any stage of the execution plan. Unplanned VUs","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/lib/helpers.go#L5-L41","documentation":"Raised by StrictJSONUnmarshal, k6's strict JSON decoding helper: after successfully decoding one JSON value there is trailing content in the input (e.g. two concatenated objects or stray tokens). It is a generic malformed-JSON guard used across options and config parsing.","triggerScenarios":"Thrown at lib/helpers.go:23 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the configuration contains exactly one JSON object or array","Remove trailing commas, duplicate objects or stray characters after the main JSON","Validate the file with a JSON linter"],"exampleFix":null,"handlingStrategy":"validation","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-14T00:17:10.932Z"}