larksuite/cli · error

invalid %s %q (want true/false/1/0)

Error message

invalid %s %q (want true/false/1/0)

What it means

parseBoolEnv parses LARKSUITE_CLI_PROXY_ENABLE. Accepted spellings (case-insensitive, trimmed): empty, 1/true/on/yes/y and 0/false/off/no/n, plus anything strconv.ParseBool accepts (t/f/T/F/TRUE/FALSE). Anything else makes transport setup fail with this error naming the env var and raw value.

Source

Thrown at internal/transport/config.go:183

}

// parseBoolEnv accepts common boolean spellings used in environment variables.
func parseBoolEnv(name, raw string) (bool, error) {
	s := strings.TrimSpace(strings.ToLower(raw))
	if s == "" {
		// Treat empty as false when explicitly present.
		return false, nil
	}
	switch s {
	case "1", "true", "on", "yes", "y":
		return true, nil
	case "0", "false", "off", "no", "n":
		return false, nil
	}
	if b, err := strconv.ParseBool(s); err == nil {
		return b, nil
	}
	return false, fmt.Errorf("invalid %s %q (want true/false/1/0)", name, raw)
}

// proxyURL validates the fixed configured proxy configuration and returns its URL.
func (c *Config) proxyURL() (*url.URL, error) {
	raw := strings.TrimSpace(c.Proxy)
	if raw == "" {
		return nil, fmt.Errorf("%s is empty", envvars.CliProxyAddress)
	}
	redacted := redactProxyURL(raw)
	u, err := url.Parse(raw)
	if err != nil {
		// Do not wrap the raw url.Parse error: its string embeds the original
		// URL, which can contain userinfo (user:password). Return a redacted,
		// generic message instead.
		return nil, fmt.Errorf("invalid %s %q: malformed URL", envvars.CliProxyAddress, redacted)
	}
	if u.Scheme != "http" {
		return nil, fmt.Errorf("invalid %s %q: scheme must be http", envvars.CliProxyAddress, redacted)

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Set the variable to a recognized boolean: `export LARKSUITE_CLI_PROXY_ENABLE=true` (or 1/on/yes/y) or false/0/off/no/n.
  2. Check for stray characters: `echo "[$LARKSUITE_CLI_PROXY_ENABLE]"` to spot quotes, spaces, or CR (Windows line endings) — unset and re-export a clean value.
  3. If the value should be off, `unset LARKSUITE_CLI_PROXY_ENABLE` or set it to 0.
  4. Remove the bad export from ~/.bashrc, ~/.zshrc, or CI env config so it doesn't recur.

Example fix

// before
export LARKSUITE_CLI_PROXY_ENABLE=enabled
// after
export LARKSUITE_CLI_PROXY_ENABLE=true
Defensive patterns

Strategy: validation

Validate before calling

v="$LARKSUITE_CLI_PROXY_ENABLE"
case "${v,,}" in ''|1|true|on|yes|y|0|false|off|no|n) echo "OK: $v" ;; *) echo "BAD value for LARKSUITE_CLI_PROXY_ENABLE: $v" >&2; exit 1 ;; esac

Prevention

When it happens

Trigger: Setting LARKSUITE_CLI_PROXY_ENABLE to a non-boolean value — e.g. `export LARKSUITE_CLI_PROXY_ENABLE=enabled`, `=2`, `=TRUE ` with a non-trimmed character like a tab, `="true"` with literal quotes, or a localized word (`=vrai`, `=ja`) — then running any CLI command.

Common situations: Copy-pasting a shell snippet where quotes became part of the value; shell profiles exporting words like "yes please" or "enabled"; CI templates using 2/yes-but-typoed values; YAML/JSON boolean literals pasted verbatim into an export.

Understand the failure class

Background: "is not a valid" / "Invalid ... value" environment variable errors: how libraries validate env vars and what to do when they reject yours — this error's family across 48 libraries.

Related errors


AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04). Data as JSON: /api/errors/58995910d3a6e3d3. Report an issue: GitHub.