{"record":{"id":"3830d38846dc7cd3","repo":"xpzouying/xiaohongshu-mcp","slug":"w-3830d3","errorCode":null,"errorMessage":"解析未读数失败: %w","messagePattern":"解析未读数失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/notification.go","lineNumber":125,"sourceCode":"\t}\n\n\tres, err := page.Eval(`() => {\n\t\tconst s = window.__INITIAL_STATE__;\n\t\tconst c = s && s.notification && s.notification.notificationCount;\n\t\treturn c ? JSON.stringify(c) : \"\";\n\t}`)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"读取未读数失败: %w\", err)\n\t}\n\n\traw := res.Value.String()\n\tif raw == \"\" {\n\t\treturn nil, fmt.Errorf(\"页面状态里没有未读数，可能未登录或页面结构已变化\")\n\t}\n\n\tvar count rawCount\n\tif err := json.Unmarshal([]byte(raw), &count); err != nil {\n\t\treturn nil, fmt.Errorf(\"解析未读数失败: %w\", err)\n\t}\n\treturn &NotificationCount{\n\t\tMentions:    count.Mentions,\n\t\tLikes:       count.Likes,\n\t\tConnections: count.Connections,\n\t\tUnread:      count.Unread,\n\t}, nil\n}\n\n// rawCount 是未读数在页面状态里的原始结构。\ntype rawCount struct {\n\tMentions    int `json:\"mentions\"`\n\tLikes       int `json:\"likes\"`\n\tConnections int `json:\"connections\"`\n\tUnread      int `json:\"unreadCount\"`\n}\n\n// List 读取指定分区的通知列表。","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/notification.go#L107-L143","documentation":"UnreadCount 拿到未读数 JSON 后 json.Unmarshal 到 rawCount 失败：notificationCount 字段结构与 rawCount 定义不符（前端改版），数据本身非合法对象。","triggerScenarios":"Thrown at xiaohongshu/notification.go:125 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["打印原始 JSON 核对字段类型","按当前页面结构更新 rawCount 字段定义"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"332d196854a9eac0d2b8c2c0e3d0cc43139d724c","analyzedAt":"2026-09-05T22:22:55.988Z","contentChangedAt":"2026-09-05T22:22:55.988Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}