{"record":{"id":"31c0887c4beb2abc","repo":"grafana/k6","slug":"parsing-k6-show-cloud-logs-returned-an-error-w","errorCode":null,"errorMessage":"parsing K6_SHOW_CLOUD_LOGS returned an error: %w","messagePattern":"parsing K6_SHOW_CLOUD_LOGS returned an error: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/cloud.go","lineNumber":136,"sourceCode":"// cmdCloud handles the `k6 cloud` sub-command\ntype cmdCloud struct {\n\tgs *state.GlobalState\n\n\tshowCloudLogs bool\n\texitOnRunning bool\n\tuploadOnly    bool\n}\n\nfunc (c *cmdCloud) preRun(cmd *cobra.Command, _ []string) error {\n\t// TODO: refactor (https://github.com/grafana/k6/issues/883)\n\t//\n\t// We deliberately parse the env variables, to validate for wrong\n\t// values, even if we don't subsequently use them (if the respective\n\t// CLI flag was specified, since it has a higher priority).\n\tif showCloudLogsEnv, ok := c.gs.Env[\"K6_SHOW_CLOUD_LOGS\"]; ok {\n\t\tshowCloudLogsValue, err := strconv.ParseBool(showCloudLogsEnv)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"parsing K6_SHOW_CLOUD_LOGS returned an error: %w\", err)\n\t\t}\n\t\tif !cmd.Flags().Changed(\"show-logs\") {\n\t\t\tc.showCloudLogs = showCloudLogsValue\n\t\t}\n\t}\n\n\tif exitOnRunningEnv, ok := c.gs.Env[\"K6_EXIT_ON_RUNNING\"]; ok {\n\t\texitOnRunningValue, err := strconv.ParseBool(exitOnRunningEnv)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"parsing K6_EXIT_ON_RUNNING returned an error: %w\", err)\n\t\t}\n\t\tif !cmd.Flags().Changed(\"exit-on-running\") {\n\t\t\tc.exitOnRunning = exitOnRunningValue\n\t\t}\n\t}\n\treturn nil\n}\n","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cmd/cloud.go#L118-L154","documentation":"The `k6 cloud` preRun hook parses K6_SHOW_CLOUD_LOGS with strconv.ParseBool and fails. ParseBool only accepts 1, t, T, true, TRUE, True, 0, f, F, false, FALSE, False; anything else (yes, on, enable, 'true ' with whitespace) is rejected. The check runs even when the --show-logs flag would override the env var, so an invalid value always aborts the command.","triggerScenarios":"K6_SHOW_CLOUD_LOGS is exported with a value outside ParseBool's accepted set, e.g. 'yes', 'on', or one containing trailing whitespace or a newline.","commonSituations":"CI systems templating boolean-looking strings ('True' with quotes included, 'yes'); Docker ENV values copied from YAML where quoting mangles the value; sharing shell profiles between tools with different boolean conventions.","solutions":["Set the variable to a strict Go boolean literal: K6_SHOW_CLOUD_LOGS=true or =false","Unset the variable if you do not need it","Use the --show-logs / --no-show-logs CLI flag instead, but note the env var must still parse if present"],"exampleFix":"# before\nexport K6_SHOW_CLOUD_LOGS=yes\n# after\nexport K6_SHOW_CLOUD_LOGS=true","handlingStrategy":"validation","validationCode":"if v, ok := os.LookupEnv(\"K6_SHOW_CLOUD_LOGS\"); ok {\n    if _, err := strconv.ParseBool(v); err != nil {\n        log.Fatalf(\"K6_SHOW_CLOUD_LOGS=%q is not a valid bool (use true/false)\", v)\n    }\n}","typeGuard":"func isValidK6Bool(v string) bool {\n    _, err := strconv.ParseBool(v)\n    return err == nil\n}","tryCatchPattern":null,"preventionTips":["Use only true/false literals in k6 env vars","Check templated CI values for surrounding whitespace or quotes","Prefer CLI flags when mixing human and automated usage"],"tags":["configuration","environment-variables","cli","boolean-parsing"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}