{"record":{"id":"a6762288e57fab52","repo":"flipped-aurora/gin-vue-admin","slug":"mcp-w-a67622","errorCode":null,"errorMessage":"解析 MCP 配置失败: %w","messagePattern":"解析 MCP 配置失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"server/cmd/mcp/config.go","lineNumber":36,"sourceCode":"type standaloneConfig struct {\n\tMCP      config.MCP      `yaml:\"mcp\"`\n\tAutoCode config.Autocode `yaml:\"autocode\"`\n}\n\nfunc loadStandaloneConfig() (string, error) {\n\tconfigPath, err := resolveConfigPath()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tcontent, err := os.ReadFile(configPath)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"读取 MCP 配置失败: %w\", err)\n\t}\n\n\tvar cfg standaloneConfig\n\tif err := yaml.Unmarshal(content, &cfg); err != nil {\n\t\treturn \"\", fmt.Errorf(\"解析 MCP 配置失败: %w\", err)\n\t}\n\n\tapplyStandaloneDefaults(configPath, &cfg)\n\n\tglobal.GVA_CONFIG.MCP = cfg.MCP\n\tglobal.GVA_CONFIG.AutoCode = cfg.AutoCode\n\n\treturn configPath, nil\n}\n\nfunc resolveConfigPath() (string, error) {\n\texplicit, err := parseConfigFlag(os.Args[1:])\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif explicit != \"\" {\n\t\treturn filepath.Abs(explicit)\n\t}","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/cmd/mcp/config.go#L18-L54","documentation":"After successfully reading the MCP config file, it is unmarshaled into standaloneConfig with yaml.Unmarshal. This error wraps a YAML parse/decode failure — the file exists but its content is not valid YAML or does not match the expected structure.","triggerScenarios":"The config file contains invalid YAML syntax (bad indentation, tabs, unclosed quotes) or fields whose types don't match standaloneConfig (e.g. string where int expected).","commonSituations":"Hand-editing YAML and introducing tab indentation; merging configs and leaving duplicate keys; type mismatch after a config schema change in a newer server version.","solutions":["Validate the YAML with a linter (yamllint or an editor plugin) to find the syntax error reported by the wrapped error","Replace tab characters with spaces for indentation","Check field names/types against the standaloneConfig struct for the server version in use","Restore from a known-good example config and reapply changes incrementally"],"exampleFix":"// before (invalid)\nmcp:\n\tapi-key: xxx\n// after\nmcp:\n  api-key: xxx","handlingStrategy":"validation","validationCode":"if err := yaml.Unmarshal(content, &standaloneConfig{}); err != nil {\n    return fmt.Errorf(\"invalid YAML in %s: %w\", configPath, err)\n}","typeGuard":null,"tryCatchPattern":"if err := yaml.Unmarshal(content, &cfg); err != nil {\n    var typeErr *yaml.TypeError\n    if errors.As(err, &typeErr) { /* print field-level mismatches */ }\n    return err\n}","preventionTips":["Lint YAML in CI before deploying configs","Use spaces, never tabs, for indentation","Keep config edits in sync with the server version's struct definitions"],"tags":["config","yaml","parse-error","startup"],"backgroundTag":"yaml-parse-error","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}