{"record":{"id":"1c9a20fbde5e5180","repo":"grafana/k6","slug":"marshalling-options-w","errorCode":null,"errorMessage":"marshalling options: %w","messagePattern":"marshalling options: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/outputs_cloud.go","lineNumber":145,"sourceCode":"\t\treturn err\n\t}\n\n\tif conf.ProjectID.Int64 == 0 {\n\t\tprojectID, err := resolveDefaultProjectID(gs, &conf)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif projectID > 0 {\n\t\t\tconf.ProjectID = null.IntFrom(projectID)\n\t\t}\n\t}\n\n\t// Marshal the resolved lib.Options as json.RawMessage for the request\n\t// body's `options` field. No map[string]any round-trip — preserves\n\t// typed precision from lib.Options custom marshalers.\n\toptionsJSON, err := json.Marshal(test.derivedConfig.Options)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"marshalling options: %w\", err)\n\t}\n\n\tctx := gs.Ctx\n\tresult, err := provClient.ProvisionLocalExecution(ctx, provisioning.ProvisionParams{\n\t\tName:          conf.Name.String,\n\t\tProjectID:     conf.ProjectID.Int64,\n\t\tMaxVUs:        int64(lib.GetMaxPossibleVUs(executionPlan)), //nolint:gosec\n\t\tTotalDuration: int64(duration / time.Second),\n\t\tOptions:       json.RawMessage(optionsJSON),\n\t\tArchive:       testArchive,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Stash testRunID in env (existing pattern).\n\ttest.preInitState.RuntimeOptions.Env[testRunIDKey] = strconv.FormatInt(result.TestRunID, 10)\n","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/cmd/outputs_cloud.go#L127-L163","documentation":"A defensive wrap in createCloudTest around json.Marshal of the resolved lib.Options for the provisioning request body. lib.Options has custom marshalers, so this only fires if an option value is fundamentally unserializable — an internal/programming error, not user input validation.","triggerScenarios":"Thrown at internal/cmd/outputs_cloud.go:145 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped marshal error to see which option field fails","Simplify unusual option values (custom types, unsupported structures) in the script's exported options","Report as a k6 bug if it reproduces with plain option values"],"exampleFix":null,"handlingStrategy":"validation","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"}