grafana/k6 · error
parsing K6_SHOW_CLOUD_LOGS returned an error: %w
Error message
parsing K6_SHOW_CLOUD_LOGS returned an error: %w
What it means
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.
Source
Thrown at internal/cmd/cloud.go:136
// cmdCloud handles the `k6 cloud` sub-command
type cmdCloud struct {
gs *state.GlobalState
showCloudLogs bool
exitOnRunning bool
uploadOnly bool
}
func (c *cmdCloud) preRun(cmd *cobra.Command, _ []string) error {
// TODO: refactor (https://github.com/grafana/k6/issues/883)
//
// We deliberately parse the env variables, to validate for wrong
// values, even if we don't subsequently use them (if the respective
// CLI flag was specified, since it has a higher priority).
if showCloudLogsEnv, ok := c.gs.Env["K6_SHOW_CLOUD_LOGS"]; ok {
showCloudLogsValue, err := strconv.ParseBool(showCloudLogsEnv)
if err != nil {
return fmt.Errorf("parsing K6_SHOW_CLOUD_LOGS returned an error: %w", err)
}
if !cmd.Flags().Changed("show-logs") {
c.showCloudLogs = showCloudLogsValue
}
}
if exitOnRunningEnv, ok := c.gs.Env["K6_EXIT_ON_RUNNING"]; ok {
exitOnRunningValue, err := strconv.ParseBool(exitOnRunningEnv)
if err != nil {
return fmt.Errorf("parsing K6_EXIT_ON_RUNNING returned an error: %w", err)
}
if !cmd.Flags().Changed("exit-on-running") {
c.exitOnRunning = exitOnRunningValue
}
}
return nil
}
View on GitHub (pinned to 93accf6570)
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
Example fix
# before export K6_SHOW_CLOUD_LOGS=yes # after export K6_SHOW_CLOUD_LOGS=true
Defensive patterns
Strategy: validation
Validate before calling
if v, ok := os.LookupEnv("K6_SHOW_CLOUD_LOGS"); ok {
if _, err := strconv.ParseBool(v); err != nil {
log.Fatalf("K6_SHOW_CLOUD_LOGS=%q is not a valid bool (use true/false)", v)
}
} Type guard
func isValidK6Bool(v string) bool {
_, err := strconv.ParseBool(v)
return err == nil
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- parsing K6_EXIT_ON_RUNNING returned an error: %w
- Run `k6 cloud login` to authenticate, or check the docs for
- access token not configured
- no project specified. Use --project-id, set K6_CLOUD_PROJECT
- 104
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/31c0887c4beb2abc.
Report an issue: GitHub.