{"record":{"id":"608b9bfafb96cc21","repo":"fish2018/pansou","slug":"v-608b9b","errorCode":null,"errorMessage":"加载站点配置失败: %v","messagePattern":"加载站点配置失败: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/gying/gying.go","lineNumber":788,"sourceCode":"\tif p.initialized {\n\t\treturn nil\n\t}\n\n\t// 初始化存储目录路径\n\tcachePath := os.Getenv(\"CACHE_PATH\")\n\tif cachePath == \"\" {\n\t\tcachePath = \"./cache\"\n\t}\n\tStorageDir = filepath.Join(cachePath, \"gying_users\")\n\n\t// 初始化存储目录\n\tif err := os.MkdirAll(StorageDir, 0755); err != nil {\n\t\treturn fmt.Errorf(\"创建存储目录失败: %v\", err)\n\t}\n\n\t// 加载站点配置\n\tif err := p.loadConfig(); err != nil {\n\t\treturn fmt.Errorf(\"加载站点配置失败: %v\", err)\n\t}\n\n\t// 加载所有用户到内存\n\tp.loadAllUsers()\n\n\t// 异步初始化默认账户（不阻塞启动）\n\tgo func() {\n\t\t// 延迟1秒，等待主程序完全启动\n\t\ttime.Sleep(1 * time.Second)\n\t\tp.initDefaultAccounts()\n\t}()\n\n\t// 启动定期清理任务\n\tgo p.startCleanupTask()\n\n\t// 启动session保活任务（防止session超时）\n\tgo p.startSessionKeepAlive()\n","sourceCodeStart":770,"sourceCodeEnd":806,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/gying/gying.go#L770-L806","documentation":"This error wraps any failure from GyingPlugin.loadConfig() during plugin initialization (Initialize). loadConfig reads the plugin's JSON config file (p.configPath()), and if the file exists but cannot be read (permissions, I/O error) or fails to json.Unmarshal (corrupt/invalid JSON, wrong schema), that error is wrapped as '加载站点配置失败: %v'. A missing file is NOT an error (it returns nil and defaults are used).","triggerScenarios":"Initialize() calls p.loadConfig() after creating the storage directory; it fails when the config file at configPath() exists but is unreadable (permission denied, disk I/O) or contains invalid JSON / unexpected field types that json.Unmarshal rejects.","commonSituations":"Config file truncated by a crash or full disk; hand-edited config with syntax errors (trailing comma, unquoted string); config written by an older plugin version whose schema no longer unmarshals into the current struct (type changed e.g. number -> string); file owned by another user after running the app with different privileges.","solutions":["Open the config file at p.configPath() and fix any JSON syntax errors (validate with jq or a JSON linter).","Check file permissions/ownership; ensure the process user can read the file (chmod 644 / chown).","If the config is corrupt or from an incompatible version, move it aside and let the plugin recreate defaults on next start.","Check the wrapped '%v' detail in the log to distinguish read errors from parse errors, then fix accordingly."],"exampleFix":"// before (corrupt config)\n{\"baseURL\": https://example.com,}   // invalid JSON -> 加载站点配置失败\n// after\n{\"baseURL\": \"https://example.com\"}   // valid JSON, loads fine","handlingStrategy":"validation","validationCode":"func isConfigLoadable(path string) error {\n    f, err := os.Open(path)\n    if err != nil { if os.IsNotExist(err) { return nil }; return err }\n    defer f.Close()\n    data, err := io.ReadAll(f)\n    if err != nil { return err }\n    var v map[string]any\n    return json.Unmarshal(data, &v)\n}\n// run before plugin Initialize; on error, repair or remove the config file","typeGuard":null,"tryCatchPattern":"if err := plugin.Initialize(ctx); err != nil {\n    if strings.Contains(err.Error(), \"加载站点配置失败\") {\n        os.Rename(cfgPath, cfgPath+\".corrupt\") // quarantine, restart with defaults\n    }\n    return err\n}","preventionTips":["Validate the plugin config JSON with a linter after every manual edit.","Never hand-edit config while the app is running (it may overwrite or race).","Back up the config file before upgrading the plugin version.","Ensure the process user owns/can read the storage directory."],"tags":["config","json","initialization","file-io"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"beaa56133755a548ebc51b090b3816e2ae044aa6","analyzedAt":"2026-09-07T00:31:18.025Z","contentChangedAt":"2026-09-07T00:31:18.025Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}