{"record":{"id":"bc4db16717562eb4","repo":"fish2018/pansou","slug":"scraper-bc4db1","errorCode":null,"errorMessage":"重新登录后scraper实例无效","messagePattern":"重新登录后scraper实例无效","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/gying/gying.go","lineNumber":2410,"sourceCode":"\t\t}\n\n\t\t// 尝试重新登录\n\t\tif reloginErr := p.reloginUser(user); reloginErr != nil {\n\t\t\tif DebugLog {\n\t\t\t\tfmt.Printf(\"[Gying] ❌ 重新登录失败: %v\\n\", reloginErr)\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"403错误且重新登录失败: %w\", reloginErr)\n\t\t}\n\n\t\t// 获取新的scraper实例\n\t\tscraperVal, exists := p.scrapers.Load(user.Hash)\n\t\tif !exists {\n\t\t\treturn nil, fmt.Errorf(\"重新登录后未找到scraper实例\")\n\t\t}\n\n\t\tnewScraper, ok := scraperVal.(*cloudscraper.Scraper)\n\t\tif !ok || newScraper == nil {\n\t\t\treturn nil, fmt.Errorf(\"重新登录后scraper实例无效\")\n\t\t}\n\n\t\t// 使用新scraper重试搜索\n\t\tif DebugLog {\n\t\t\tfmt.Printf(\"[Gying] 🔄 使用新登录状态重试搜索\\n\")\n\t\t}\n\t\tresults, err = p.searchWithScraper(keyword, newScraper)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"重新登录后搜索仍然失败: %w\", err)\n\t\t}\n\t\tif syncErr := p.syncUserCookiesFromScraper(user, newScraper); syncErr != nil && DebugLog {\n\t\t\tfmt.Printf(\"[Gying] ⚠️  重登搜索后同步用户 %s Cookie失败: %v\\n\", user.Username, syncErr)\n\t\t}\n\t}\n\n\treturn results, err\n}\n","sourceCodeStart":2392,"sourceCodeEnd":2428,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/gying/gying.go#L2392-L2428","documentation":"Internal invariant error: after re-login, the value stored in p.scrapers for user.Hash could not be asserted to a non-nil *cloudscraper.Scraper. The map should only ever contain Scraper instances stored by doLogin/reloginUser.","triggerScenarios":"scraperVal.(*cloudscraper.Scraper) type assertion fails or the asserted pointer is nil — e.g. something stored a different type under the user's hash, or a nil scraper was stored.","commonSituations":"Code changes introduced another entry type into p.scrapers; a failed login path stored nil; mixing plugin versions sharing the same scraper map.","solutions":["Audit all p.scrapers.Store calls to ensure only *cloudscraper.Scraper values are stored.","Ensure doLogin never returns a nil scraper with a nil error.","Retry the request; if persistent, report as a plugin bug.","Re-login the user from scratch to repopulate a valid scraper."],"exampleFix":"// before (doLogin failure path)\nreturn nil, nil\n// after\nreturn nil, fmt.Errorf(\"login failed\") // never return nil scraper with nil error","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"newScraper, ok := scraperVal.(*cloudscraper.Scraper)\nif !ok || newScraper == nil {\n    return errors.New(\"invalid scraper stored; force re-login\")\n}","tryCatchPattern":null,"preventionTips":["Only store *cloudscraper.Scraper values into p.scrapers.","Never return a nil scraper together with a nil error from doLogin.","Run a nil/type check after every Store/Load pair in plugin code."],"tags":["type-assertion","internal-state","scraper"],"backgroundTag":"type-mismatch","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"}