{"record":{"id":"153aec1b8fbdffee","repo":"fish2018/pansou","slug":"code-t-v","errorCode":null,"errorMessage":"无法解析code字段，类型: %T, 值: %v","messagePattern":"无法解析code字段，类型: %T, 值: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/gying/gying.go","lineNumber":2200,"sourceCode":"\tvar codeValue int\n\tcodeInterface := loginResp[\"code\"]\n\n\tswitch v := codeInterface.(type) {\n\tcase int:\n\t\tcodeValue = v\n\tcase float64:\n\t\tcodeValue = int(v)\n\tcase int64:\n\t\tcodeValue = int(v)\n\tdefault:\n\t\t// 尝试转换为字符串再解析\n\t\tcodeStr := fmt.Sprintf(\"%v\", codeInterface)\n\t\tparsed, err := strconv.Atoi(codeStr)\n\t\tif err != nil {\n\t\t\tif DebugLog {\n\t\t\t\tfmt.Printf(\"[Gying] 无法解析code字段: %T, 值: %v, 错误: %v\\n\", codeInterface, codeInterface, err)\n\t\t\t}\n\t\t\treturn nil, \"\", fmt.Errorf(\"无法解析code字段，类型: %T, 值: %v\", codeInterface, codeInterface)\n\t\t}\n\t\tcodeValue = parsed\n\t}\n\n\tif DebugLog {\n\t\tfmt.Printf(\"[Gying] 解析后的code值: %d\\n\", codeValue)\n\t}\n\n\tif codeValue != 200 {\n\t\tif DebugLog {\n\t\t\tfmt.Printf(\"[Gying] 登录失败: code=%d (期望200)\\n\", codeValue)\n\t\t}\n\t\treturn nil, \"\", fmt.Errorf(\"登录失败: code=%d, 响应=%s\", codeValue, string(body))\n\t}\n\n\t// ========== 步骤3: GET详情页 (触发防爬cookies如vrg_sc、vrg_go等) ==========\n\tif DebugLog {\n\t\tfmt.Printf(\"[Gying] 步骤3: GET详情页收集完整Cookie\\n\")","sourceCodeStart":2182,"sourceCodeEnd":2218,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/gying/gying.go#L2182-L2218","documentation":"The parsed login JSON stores its 'code' field as interface{}, so gying converts it via fmt.Sprintf(\"%v\") + strconv.Atoi. If the value is neither a number nor a numeric string (e.g. bool, nested object, or missing→nil), Atoi fails and the plugin returns '无法解析code字段，类型: %T, 值: %v', reporting the Go type and value it couldn't parse.","triggerScenarios":"Login response JSON contains a 'code' field whose value is not numeric — a string like \"ok\", an object, a boolean, or the field is absent so codeInterface is nil.","commonSituations":"Site changed its login API response schema (code moved/renamed, became a string status); response is actually an error payload with a different shape; partial/HTML-ish body that unmarshaled as something unexpected.","solutions":["Log the full raw response body and check the actual shape of the 'code' field against the error's %T/%v output.","Compare with the site's current API docs or a manual login (browser devtools) to see the new response schema.","Update the plugin to handle the new schema (e.g. accept string statuses or a renamed field).","If the field is missing entirely, the endpoint likely returned an error payload — fix the request (credentials, cookies) and retry."],"exampleFix":"// before: only numeric/string-numeric accepted\nparsed, err := strconv.Atoi(codeStr)\n// after: also treat a bool-style or mapped status defensively\nif s, ok := codeInterface.(string); ok {\n    parsed, err = strconv.Atoi(strings.TrimSpace(s))\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func codeFieldIsNumeric(loginResp map[string]interface{}) bool {\n    switch v := loginResp[\"code\"].(type) {\n    case float64, int, string:\n        return true\n    default:\n        _ = v\n        return false\n    }\n}","tryCatchPattern":null,"preventionTips":["Log the raw login response whenever the schema might have changed.","Validate response shape before interpreting business fields.","Update plugin handling if the site converts code to a string status.","Treat missing 'code' as an error-payload signal, not a parse bug."],"tags":["json","type-mismatch","login","unexpected-response"],"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"}