siyuan-note/siyuan · warning

name is empty

Error message

name is empty

What it means

Validation sentinel from validateEnvironmentName: an empty string was supplied where an environment variable name is required. It fires inside validateMCPServerEnvironment while iterating either server.InheritEnv (a slice, so an empty element is possible) or server.Env (map keys, which can also be the empty string). This is a config-shape defect, not a runtime condition.

Source

Thrown at kernel/mcp/client/mcp.go:536

	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] = true

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Open the MCP server config and remove the empty entry from InheritEnv or the empty key from Env.
  2. If config is built programmatically, filter out empty names before writing: inheritEnv = slices.DeleteFunc(inheritEnv, func(s string) bool { return s == "" }).
  3. Validate with ValidateMCPServerEnvironment at config-save time so this is reported in the UI, not at server start.

Example fix

// before
"inheritEnv": ["PATH", "", "HOME"]
// after
"inheritEnv": ["PATH", "HOME"]
Defensive patterns

Strategy: validation

Validate before calling

import "slices"
func dropEmpty(names []string) []string {
    return slices.DeleteFunc(append([]string(nil), names...), func(s string) bool { return s == "" })
}

Prevention

When it happens

Trigger: server.InheritEnv contains an empty string element (e.g. ["PATH", "", "HOME"]) or server.Env has a key equal to "". validateMCPServerEnvironment calls validateEnvironmentName(""), which returns this error before connectStdio can spawn the child.

Common situations: Hand-edited MCP config JSON with a trailing comma or empty array element like "inheritEnv": ["PATH", ""]; UI form that submitted an empty 'add variable' row; programmatic config generator that appended an empty identifier.

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/b706b896d3049499. Report an issue: GitHub.