{"record":{"id":"bd218fd041283b23","repo":"fish2018/pansou","slug":"anubis-w-bd218f","errorCode":null,"errorMessage":"创建 Anubis 验证提交请求失败: %w","messagePattern":"创建 Anubis 验证提交请求失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/miosou/miosou.go","lineNumber":198,"sourceCode":"\tstartedAt := time.Now()\n\thash, nonce, err := solveAnubisChallenge(ctx, challenge.Challenge.RandomData, challenge.Rules.Difficulty)\n\tif err != nil {\n\t\treturn err\n\t}\n\telapsed := time.Since(startedAt).Milliseconds()\n\tif elapsed < 1 {\n\t\telapsed = 1\n\t}\n\tquery := url.Values{\n\t\t\"id\":          []string{challenge.Challenge.ID},\n\t\t\"response\":    []string{hash},\n\t\t\"nonce\":       []string{strconv.FormatUint(nonce, 10)},\n\t\t\"redir\":       []string{baseURL + \"/\"},\n\t\t\"elapsedTime\": []string{strconv.FormatInt(elapsed, 10)},\n\t}\n\tpassReq, err := http.NewRequestWithContext(ctx, http.MethodGet, baseURL+anubisPassPath+\"?\"+query.Encode(), nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"创建 Anubis 验证提交请求失败: %w\", err)\n\t}\n\tsetPageHeaders(passReq)\n\tpassReq.Header.Set(\"Referer\", resp.Request.URL.String())\n\tpassResp, err := p.client.Do(passReq)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"提交 Anubis 验证结果失败: %w\", err)\n\t}\n\tio.Copy(io.Discard, io.LimitReader(passResp.Body, 1<<20))\n\tpassResp.Body.Close()\n\tif passResp.StatusCode != http.StatusOK || isAnubisGateResponse(passResp) {\n\t\treturn fmt.Errorf(\"Anubis 验证结果返回状态码 %d\", passResp.StatusCode)\n\t}\n\treturn nil\n}\n\nfunc (p *MiosouPlugin) invalidateGate() {\n\tp.gateMu.Lock()\n\tp.gateReady = false","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/miosou/miosou.go#L180-L216","documentation":"After solving the proof-of-work, the plugin builds a GET to baseURL+anubisPassPath with query params (id, response, nonce, redir, elapsedTime) via http.NewRequestWithContext. This error wraps a malformed-URL / bad-method failure at request construction (miosou.go:198).","triggerScenarios":"http.NewRequestWithContext fails — practically only when baseURL+anubisPassPath is not a parseable URL or the query encoding produces an invalid URL; ctx is nil.","commonSituations":"A misconfigured baseURL constant (empty string, missing scheme, embedded spaces/newline) breaking url.Parse; an empty anubisPassPath making the URL invalid in some builds.","solutions":["Verify baseURL and anubisPassPath constants form a valid absolute URL (print/parse them).","Validate baseURL at startup with url.Parse and fail fast if invalid.","This is a build/config bug, not transient — no retry needed; fix the constants."],"exampleFix":"// before\nbaseURL := \"\" // misconfigured\n// after\nu, err := url.Parse(baseURL)\nif err != nil || u.Scheme == \"\" || u.Host == \"\" {\n    return fmt.Errorf(\"invalid baseURL %q: %w\", baseURL, err)\n}","handlingStrategy":"validation","validationCode":"u, err := url.Parse(baseURL + anubisPassPath)\nif err != nil || u.Scheme == \"\" || u.Host == \"\" {\n    return fmt.Errorf(\"invalid Anubis pass URL: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := p.ensureGate(); err != nil {\n    if strings.Contains(err.Error(), \"创建 Anubis 验证提交请求失败\") {\n        // configuration bug: fail fast, do not retry\n    }\n    return err\n}","preventionTips":["Validate baseURL at plugin init with url.Parse","Keep baseURL and anubisPassPath as verified constants","Add a startup self-test that constructs the pass URL"],"tags":["url","http","anubis","configuration"],"backgroundTag":"invalid-url","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"}