{"record":{"id":"9f614ec54663fcdc","repo":"grafana/k6","slug":"unqouting-k6-instance-scenarios-w","errorCode":null,"errorMessage":"unqouting K6_INSTANCE_SCENARIOS: %w","messagePattern":"unqouting K6_INSTANCE_SCENARIOS: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/registry.go","lineNumber":126,"sourceCode":"\t}\n\n\treturn true, parts\n}\n\n// checkForScenarios will parse the K6_INSTANCE_SCENARIOS env var if\n// it has been defined.\nfunc checkForScenarios(envLookup env.LookupFunc) (bool, []string, error) {\n\tscenariosJSON, isRemote := envLookup(env.InstanceScenarios)\n\tif !isRemote {\n\t\treturn false, nil, nil\n\t}\n\t// prevent failing in unquoting empty string.\n\tif scenariosJSON == \"\" {\n\t\treturn false, nil, nil\n\t}\n\tscenariosJSON, err := strconv.Unquote(scenariosJSON)\n\tif err != nil {\n\t\treturn false, nil, fmt.Errorf(\"unqouting K6_INSTANCE_SCENARIOS: %w\", err)\n\t}\n\n\tvar scenarios []struct {\n\t\tID       string `json:\"id\"`\n\t\tBrowsers []struct {\n\t\t\tHandle string `json:\"handle\"`\n\t\t} `json:\"browsers\"`\n\t}\n\tif err := json.Unmarshal([]byte(scenariosJSON), &scenarios); err != nil {\n\t\treturn false, nil, fmt.Errorf(\"parsing K6_INSTANCE_SCENARIOS: %w\", err)\n\t}\n\n\tvar wsURLs []string\n\tfor _, s := range scenarios {\n\t\tfor _, b := range s.Browsers {\n\t\t\tif strings.TrimSpace(b.Handle) == \"\" {\n\t\t\t\tcontinue\n\t\t\t}","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/browser/registry.go#L108-L144","documentation":"Thrown by the k6 browser registry at startup when the K6_INSTANCE_SCENARIOS environment variable is defined and non-empty but strconv.Unquote cannot parse it as a Go-quoted string. The variable is an internal coordination channel (set by k6 when browser scenarios run with a remote/browser cloud setup) carrying a double-quoted, escape-encoded JSON payload; a raw unquoted JSON value fails unquoting.","triggerScenarios":"Manually exporting K6_INSTANCE_SCENARIOS='[{\"id\":\"x\",...}]' (raw JSON, no outer Go quotes); double-quoting inconsistencies or trailing backslashes that break escape sequences; env injection tools (Docker ENV, CI secrets) that mangle inner quotes.","commonSituations":"Trying to simulate or debug remote-browser orchestration locally by hand-setting the variable; wrapper scripts or CI templates that JSON-encode the value twice or not at all; version changes in how k6 passes scenario metadata between processes.","solutions":["Unset K6_INSTANCE_SCENARIOS unless k6 itself is orchestrating the run: the local browser module works without it.","If you must emulate it, wrap the JSON in Go-style double quotes with escaped inner quotes so strconv.Unquote succeeds.","Verify the exact value with a print of the env var before launch to spot mangling by Docker/CI.","Upgrade k6 to a matching version so launcher and browser module agree on the variable's format."],"exampleFix":"# before\nexport K6_INSTANCE_SCENARIOS='[{\"id\":\"s1\",\"browsers\":[{\"handle\":\"ws://host\"}]}]'\n\n# after (unset for local runs)\nunset K6_INSTANCE_SCENARIOS\n# or, if emulating the internal format:\nexport K6_INSTANCE_SCENARIOS='\"[{\\\"id\\\":\\\"s1\\\",\\\"browsers\\\":[{\\\"handle\\\":\\\"ws://host\\\"}]}]\"'","handlingStrategy":"validation","validationCode":"# Only k6 itself should set this; verify it is either absent or a Go-quoted string\nif [ -n \"$K6_INSTANCE_SCENARIOS\" ] && [ \"${K6_INSTANCE_SCENARIOS:0:1}\" != '\"' ]; then\n  echo \"K6_INSTANCE_SCENARIOS must be unset or a quoted payload\" >&2\n  exit 1\nfi\nk6 run script.js","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not set K6_INSTANCE_SCENARIOS manually; it is internal coordination state for remote browser scenarios.","In Docker/CI, audit which environment variables leak into the k6 process.","Keep launcher and k6 binary versions in sync so the payload format matches."],"tags":["k6","browser","environment-variable","startup","configuration"],"backgroundTag":"malformed-env-var","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"}