siyuan-note/siyuan · error
name is empty
Error message
name is empty
What it means
validateEnvironmentName is part of stdio MCP server environment validation: every InheritEnv and Env key must be a non-empty string that contains no '=' or NUL byte, because these characters cannot appear in a NAME=VALUE environment entry. An empty key triggers this bare "name is empty" error before the subprocess starts.
Solutions
- Remove empty-string entries from InheritEnv and delete any "" key from the Env map
- Provide the actual variable name, e.g. {"Env": {"MY_VAR": "value"}}
- Re-save the MCP server configuration through the UI so the environment fields are rebuilt correctly
- Add a pre-save check that every env name is non-empty and free of '=' and NUL
Example fix
// before "inheritEnv": ["PATH", ""] // after "inheritEnv": ["PATH"]
Defensive patterns
Strategy: validation
Validate before calling
func validEnvNames(names []string) bool {
for _, n := range names {
if n == "" || strings.ContainsAny(n, "=\x00") {
return false
}
}
return true
} Type guard
null
Try / catch
if err := validateMCPServerEnvironment(server, runtime.GOOS); err != nil {
return fmt.Errorf("environment config invalid for server %q: %w", server.Name, err)
} Prevention
- Reject empty-string keys when serializing Env config to JSON
- Run the same name validation in the settings UI before persisting
- Generate config programmatically with schema checks that require non-empty map keys
When it happens
Trigger: validateMCPServerEnvironment iterates server.InheritEnv or server.Env and passes an empty-string name to validateEnvironmentName — e.g. an InheritEnv array containing "" or an Env JSON object with an empty key.
Common situations: Malformed config JSON with {"": "value"}, an InheritEnv list with a trailing empty entry, programmatic config generation that left a name unset, or hand-editing that removed the variable name but kept the value.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- attr must be a string or null (got %T)
- each key must be an object
- each key requires name and type
- environment
- field [file] or [url] must not be empty
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/b706b896d3049499.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/mcp/client/mcp.go:538
sort.Strings(keys)
ret := make([]string, 0, len(keys))
for _, key := range keys {
entry := entries[key]
ret = append(ret, entry.name+"="+entry.value)
}
return ret, nil
}
func environmentKey(name, goos string) string {
if goos == "windows" {
return strings.ToUpper(name)
}
return name
}
func validateEnvironmentName(name string) error {
if name == "" {
return errors.New("name is empty")
}
if strings.ContainsAny(name, "=\x00") {
return fmt.Errorf("invalid name %q", name)
}
return nil
}
func validateMCPServerEnvironment(server conf.MCPServer, goos string) error {
inherited := map[string]bool{}
for _, name := range server.InheritEnv {
if err := validateEnvironmentName(name); err != nil {
return err
}
key := environmentKey(name, goos)
if inherited[key] {
return fmt.Errorf("duplicate inherited variable %q", name)
}
inherited[key] = trueView on GitHub (pinned to 9f775e8a12)