sipeed/picoclaw · error
invalid env assignment %q: key cannot be empty
Error message
invalid env assignment %q: key cannot be empty
What it means
Second guard of parseEnvAssignments (helpers.go:224-227): the entry contained '=' but the key side is empty after trimming. The parser deliberately rejects '=value' and ' =value' rather than storing a nameless variable.
Source
Thrown at cmd/picoclaw/internal/mcp/helpers.go:226
}
sort.Strings(names)
return names
}
func parseEnvAssignments(values []string) (map[string]string, error) {
if len(values) == 0 {
return nil, nil
}
env := make(map[string]string, len(values))
for _, entry := range values {
key, value, found := strings.Cut(entry, "=")
if !found {
return nil, fmt.Errorf("invalid env assignment %q: expected KEY=value", entry)
}
key = strings.TrimSpace(key)
if key == "" {
return nil, fmt.Errorf("invalid env assignment %q: key cannot be empty", entry)
}
env[key] = value
}
return env, nil
}
func parseHeaderAssignments(values []string) (map[string]string, error) {
if len(values) == 0 {
return nil, nil
}
headers := make(map[string]string, len(values))
for _, entry := range values {
key, value, found := strings.Cut(entry, ":")
if !found {
key, value, found = strings.Cut(entry, "=")
}View on GitHub (pinned to 49183d7e8d)
Solutions
- Put the variable name before the equals sign: -e API_KEY=secret
- Inspect the exact argument with printf '%s\n' "$PAIR" | cat -A to reveal leading whitespace
Example fix
# before picoclaw mcp add s ./server -e "=secret" # after picoclaw mcp add s ./server -e "API_KEY=secret"
Defensive patterns
Strategy: validation
Validate before calling
validate_env() {
local pair=$1
[[ $pair == *=* ]] || { echo "need KEY=value" >&2; return 1; }
local key=${pair%%=*}
[[ -n "${key//[[:space:]]/}" ]] || { echo "empty key in '$pair'" >&2; return 1; }
}
validate_env "$pair" && picoclaw mcp add "$name" "$target" -e "$pair" Prevention
- Keep the key flush against '=' with no leading whitespace
- Check paste artifacts with cat -A when assignments misbehave
When it happens
Trigger: `-e =foo`, `-e " =foo"`, or a paste that put the value before the equals sign.
Common situations: Copy-paste artifacts; retyping an assignment and swapping the sides; macros/snippets emitting a leading space.
Related errors
- invalid env assignment %q: expected KEY=value
- unsupported --type %q (only 'openai-compatible' is supported
- api base is required
- either --every or --cron must be specified
- invalid --host value: %w
AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15).
Data as JSON: /api/errors/c81f6bf553f8374f.
Report an issue: GitHub.