{"record":{"id":"25542cf17958baaf","repo":"grafana/k6","slug":"could-not-serialize-cloud-configuration-w","errorCode":null,"errorMessage":"could not serialize cloud configuration: %w","messagePattern":"could not serialize cloud configuration: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/outputs_cloud.go","lineNumber":241,"sourceCode":"\ttoken := gs.Env[\"K6_CLOUD_TEST_RUN_TOKEN\"]\n\tif (pushURL == \"\") != (token == \"\") {\n\t\treturn errors.New(\"both K6_CLOUD_METRICS_PUSH_URL and \" +\n\t\t\t\"K6_CLOUD_TEST_RUN_TOKEN must be set together\")\n\t}\n\t// A logs push URL is authenticated with the same scoped token, so reject a\n\t// logs URL supplied without it rather than silently streaming nothing.\n\tif token == \"\" && conf.LogsPushURL.Valid && conf.LogsPushURL.String != \"\" {\n\t\treturn errors.New(\"K6_CLOUD_LOGS_PUSH_URL requires K6_CLOUD_TEST_RUN_TOKEN\")\n\t}\n\tif pushURL == \"\" {\n\t\treturn nil\n\t}\n\n\tconf.MetricsPushURL = null.StringFrom(pushURL)\n\tconf.TestRunToken = null.StringFrom(token)\n\traw, err := cloudConfToRawMessage(*conf)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not serialize cloud configuration: %w\", err)\n\t}\n\tif test.derivedConfig.Collectors == nil {\n\t\ttest.derivedConfig.Collectors = make(map[string]json.RawMessage)\n\t}\n\ttest.derivedConfig.Collectors[builtinOutputCloud.String()] = raw\n\treturn nil\n}\n\n// externalLogsConfig mirrors the K6_CLOUD_LOGS_* env vars an external\n// orchestrator uses to hand the log-push settings to a local k6. These are\n// read explicitly (the Logs* fields are not env-bound on cloudapi.Config) so a\n// stray env value can't override the run-scoped logs config in the\n// self-provisioned flow.\ntype externalLogsConfig struct {\n\tPushURL       null.String        `envconfig:\"K6_CLOUD_LOGS_PUSH_URL\"`\n\tLevel         null.String        `envconfig:\"K6_CLOUD_LOGS_LEVEL\"`\n\tLimit         null.Int           `envconfig:\"K6_CLOUD_LOGS_LIMIT\"`\n\tPushPeriod    types.NullDuration `envconfig:\"K6_CLOUD_LOGS_PUSH_PERIOD\"`","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/cmd/outputs_cloud.go#L223-L259","documentation":"Generic wrap in applyExternalProvisioningCreds around serializing the final cloud configuration (after injecting externally provisioned credentials such as K6_CLOUD_METRICS_PUSH_URL/K6_CLOUD_TEST_RUN_TOKEN). The %w names the underlying marshal failure; internal invariant rather than user error.","triggerScenarios":"Thrown at internal/cmd/outputs_cloud.go:241 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped serialization error","Verify cloud env vars are not set to values with unexpected characters or types","Report as a bug if it reproduces with a normal provisioning setup"],"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"}