{"record":{"id":"123699a4d08b7753","repo":"fish2018/pansou","slug":"pow-n","errorCode":null,"errorMessage":"PoW验证数据无效: N","messagePattern":"PoW验证数据无效: N","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/gying/gying.go","lineNumber":1740,"sourceCode":"\nfunc (p *GyingPlugin) solvePowChallenge(scraper *cloudscraper.Scraper, requestURL string, challenge *ChallengePageData) error {\n\ty, err := p.computePowResult(challenge)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tform := url.Values{}\n\tform.Set(\"action\", \"verify\")\n\tform.Set(\"id\", challenge.ID)\n\tform.Set(\"y\", y)\n\n\treturn p.submitChallengeVerification(scraper, requestURL, form)\n}\n\nfunc (p *GyingPlugin) computePowResult(challenge *ChallengePageData) (string, error) {\n\tmodulus, ok := new(big.Int).SetString(challenge.N, 16)\n\tif !ok || modulus.Sign() <= 0 {\n\t\treturn \"\", fmt.Errorf(\"PoW验证数据无效: N\")\n\t}\n\n\ty, ok := new(big.Int).SetString(challenge.X, 16)\n\tif !ok || y.Sign() < 0 {\n\t\treturn \"\", fmt.Errorf(\"PoW验证数据无效: x\")\n\t}\n\tif challenge.T <= 0 {\n\t\treturn \"\", fmt.Errorf(\"PoW验证数据无效: t\")\n\t}\n\n\tif DebugLog {\n\t\tfmt.Printf(\"[Gying] PoW Challenge计算开始: id=%s t=%d nBits=%d\\n\",\n\t\t\tchallenge.ID, challenge.T, modulus.BitLen())\n\t}\n\n\tstart := time.Now()\n\tfor i := 0; i < challenge.T; i++ {\n\t\ty.Mul(y, y)","sourceCodeStart":1722,"sourceCodeEnd":1758,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/gying/gying.go#L1722-L1758","documentation":"computePowResult parses the challenge's RSA-like modulus N from hex via big.Int.SetString before repeatedly squaring x mod N. This error is returned when N is empty, not valid hex, or parses to zero or a negative number, so the modular squaring loop cannot run safely. It indicates the challenge payload delivered by the site is malformed or was not populated.","triggerScenarios":"solvePowChallenge or the direct /res/pow path calls computePowResult with a ChallengePageData whose N field is not a non-empty, positive hex string (e.g. N=\"\", N=\"xyz\", N=\"0\" or N=\"-1\").","commonSituations":"The upstream bot-protection endpoint changed its response schema so the modulus arrives under a different JSON key; a proxy or captive portal returned HTML/garbage that partially matched the JSON; a cached/stale challenge object was reused after its fields were cleared.","solutions":["Log challenge.N (and the raw response body) before calling computePowResult to confirm what the server actually returned","Re-fetch a fresh challenge from /res/pow; a stale or truncated challenge is the usual cause","If the site changed its payload shape, update ChallengePageData's JSON field mapping for N","Reject the challenge client-side before calling the solver: validate N is non-empty hex with a positive value"],"exampleFix":"// before\nmodulus, ok := new(big.Int).SetString(challenge.N, 16)\n// after (guard upstream too)\nif challenge.N == \"\" || challenge.T <= 0 {\n    return fmt.Errorf(\"PoW验证数据无效: N\")\n}\nmodulus, ok := new(big.Int).SetString(strings.TrimPrefix(challenge.N, \"0x\"), 16)","handlingStrategy":"validation","validationCode":"func validHexPositive(s string) bool {\n    n, ok := new(big.Int).SetString(strings.TrimPrefix(s, \"0x\"), 16)\n    return ok && n.Sign() > 0\n}\nif !validHexPositive(ch.N) { /* re-fetch challenge before solving */ }","typeGuard":"func isValidPowModulus(c *ChallengePageData) bool {\n    n, ok := new(big.Int).SetString(c.N, 16)\n    return ok && n != nil && n.Sign() > 0\n}","tryCatchPattern":"y, err := p.computePowResult(challenge)\nif err != nil {\n    if strings.Contains(err.Error(), \"PoW验证数据无效\") {\n        return p.refetchAndSolve(scraper, requestURL) // re-fetch fresh challenge\n    }\n    return err\n}","preventionTips":["Always fetch a fresh challenge immediately before solving; never reuse cached ChallengePageData","Log the raw challenge response body when DebugLog is enabled","Validate N/X/T right after json.Unmarshal, before dispatching to a solver"],"tags":["pow","challenge","hex-parsing","anti-bot"],"backgroundTag":"invalid-argument-format","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"}