sipeed/picoclaw · error
invalid env assignment %q: expected KEY=value
Error message
invalid env assignment %q: expected KEY=value
What it means
parseEnvAssignments (helpers.go:213-232) requires every -e/--env value to contain '='; strings.Cut without a separator yields this error. The value side may be empty (KEY= is legal), but the separator itself is mandatory.
Source
Thrown at cmd/picoclaw/internal/mcp/helpers.go:222
func sortedServerNames(servers map[string]config.MCPServerConfig) []string {
names := make([]string, 0, len(servers))
for name := range servers {
names = append(names, name)
}
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 {View on GitHub (pinned to 49183d7e8d)
Solutions
- Pass explicit KEY=value form: -e API_KEY=secret
- Expand the pair yourself: -e "API_KEY=$API_KEY"
- For secrets prefer --env-file (the flag help recommends it) so values stay out of shell history
Example fix
# before picoclaw mcp add s ./server -e API_KEY # after picoclaw mcp add s ./server -e "API_KEY=$API_KEY"
Defensive patterns
Strategy: validation
Validate before calling
for pair in "${ENVS[@]}"; do
case "$pair" in
*=*) ;;
*) echo "invalid env assignment '$pair': expected KEY=value" >&2; exit 2 ;;
esac
done
picoclaw mcp add "$name" "$target" "${ENVS[@]/#/-e }" Prevention
- Always write -e KEY=value; this CLI does not accept bare names like docker does
- Expand inline: -e "KEY=$KEY" instead of -e "$KEY"
When it happens
Trigger: `picoclaw mcp add s ./server -e API_KEY` (forgot =value); quoting that strips the pair, e.g. -e "$VAR" where VAR is unset so the argument becomes a bare word.
Common situations: Intending to forward a variable that holds its own value; muscle memory from `docker run -e VAR` which accepts bare names (this CLI does not).
Related errors
- invalid env assignment %q: key cannot be empty
- 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/8a50559c33b47f38.
Report an issue: GitHub.