{"record":{"id":"f17a3873e1f3eadd","repo":"siyuan-note/siyuan","slug":"invalid-name-q","errorCode":null,"errorMessage":"invalid name %q","messagePattern":"invalid name %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kernel/mcp/client/mcp.go","lineNumber":539,"sourceCode":"\t\tentry := entries[key]\n\t\tret = append(ret, entry.name+\"=\"+entry.value)\n\t}\n\treturn ret, nil\n}\n\nfunc environmentKey(name, goos string) string {\n\tif goos == \"windows\" {\n\t\treturn strings.ToUpper(name)\n\t}\n\treturn name\n}\n\nfunc validateEnvironmentName(name string) error {\n\tif name == \"\" {\n\t\treturn errors.New(\"name is empty\")\n\t}\n\tif strings.ContainsAny(name, \"=\\x00\") {\n\t\treturn fmt.Errorf(\"invalid name %q\", name)\n\t}\n\treturn nil\n}\n\nfunc validateMCPServerEnvironment(server conf.MCPServer, goos string) error {\n\tinherited := map[string]bool{}\n\tfor _, name := range server.InheritEnv {\n\t\tif err := validateEnvironmentName(name); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tkey := environmentKey(name, goos)\n\t\tif inherited[key] {\n\t\t\treturn fmt.Errorf(\"duplicate inherited variable %q\", name)\n\t\t}\n\t\tinherited[key] = true\n\t}\n\texplicit := map[string]bool{}\n\tfor name, value := range server.Env {","sourceCodeStart":521,"sourceCodeEnd":557,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/mcp/client/mcp.go#L521-L557","documentation":"Validation error from validateEnvironmentName: the environment variable name contains '=' or a NUL byte (\\x00). Both characters are illegal in env var names on every supported platform — '=' would break the KEY=VALUE serialization in buildStdioEnvironment, and NUL cannot appear in a C-string environ entry. The offending name is quoted via %q.","triggerScenarios":"A name in server.InheritEnv or a key in server.Env contains '=' or '\\x00'. validateMCPServerEnvironment calls validateEnvironmentName, which runs strings.ContainsAny(name, \"=\\x00\") and returns this error.","commonSituations":"User mistakenly wrote an entire assignment like \"API_KEY=secret\" inside the inheritEnv array instead of a bare name; copy-paste of a 'KEY=value' line from a .env file into the name field; corrupted config containing a control character.","solutions":["Split the offending entry: if you wrote \"KEY=value\" inside inheritEnv, move it to the env object as {\"KEY\":\"value\"} and keep only \"KEY\" in inheritEnv.","Strip any '=' or NUL characters from the name field in the config.","Re-run ValidateMCPServerEnvironment to confirm the fix."],"exampleFix":"// before\n\"inheritEnv\": [\"API_KEY=secret\"]\n// after\n\"inheritEnv\": [],\n\"env\": {\"API_KEY\": \"secret\"}","handlingStrategy":"validation","validationCode":"import \"strings\"\nfunc cleanEnvName(name string) (string, error) {\n    if name == \"\" { return \"\", errors.New(\"empty\") }\n    if strings.ContainsAny(name, \"=\\x00\") { return \"\", fmt.Errorf(\"invalid %q\", name) }\n    return name, nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Put full KEY=value pairs in env, not inheritEnv.","Strip '=' and NUL from any name before writing config."],"tags":["mcp","environment","config-validation"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}