grafana/k6 · error
marshalling options
Error message
marshalling options: %w
What it means
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.
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/cmd/outputs_cloud.go:145 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/1c9a20fbde5e5180.
Report an issue: GitHub.
Appendix: source
Thrown at internal/cmd/outputs_cloud.go:145
return err
}
if conf.ProjectID.Int64 == 0 {
projectID, err := resolveDefaultProjectID(gs, &conf)
if err != nil {
return err
}
if projectID > 0 {
conf.ProjectID = null.IntFrom(projectID)
}
}
// Marshal the resolved lib.Options as json.RawMessage for the request
// body's `options` field. No map[string]any round-trip — preserves
// typed precision from lib.Options custom marshalers.
optionsJSON, err := json.Marshal(test.derivedConfig.Options)
if err != nil {
return fmt.Errorf("marshalling options: %w", err)
}
ctx := gs.Ctx
result, err := provClient.ProvisionLocalExecution(ctx, provisioning.ProvisionParams{
Name: conf.Name.String,
ProjectID: conf.ProjectID.Int64,
MaxVUs: int64(lib.GetMaxPossibleVUs(executionPlan)), //nolint:gosec
TotalDuration: int64(duration / time.Second),
Options: json.RawMessage(optionsJSON),
Archive: testArchive,
})
if err != nil {
return err
}
// Stash testRunID in env (existing pattern).
test.preInitState.RuntimeOptions.Env[testRunIDKey] = strconv.FormatInt(result.TestRunID, 10)
View on GitHub (pinned to 01ffac6f24)