fish2018/pansou · error

创建 Anubis 验证提交请求失败

Error message

创建 Anubis 验证提交请求失败: %w

What it means

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).

Solutions

  1. Verify baseURL and anubisPassPath constants form a valid absolute URL (print/parse them).
  2. Validate baseURL at startup with url.Parse and fail fast if invalid.
  3. This is a build/config bug, not transient — no retry needed; fix the constants.

Example fix

// before
baseURL := "" // misconfigured
// after
u, err := url.Parse(baseURL)
if err != nil || u.Scheme == "" || u.Host == "" {
    return fmt.Errorf("invalid baseURL %q: %w", baseURL, err)
}
Defensive patterns

Strategy: validation

Validate before calling

u, err := url.Parse(baseURL + anubisPassPath)
if err != nil || u.Scheme == "" || u.Host == "" {
    return fmt.Errorf("invalid Anubis pass URL: %w", err)
}

Try / catch

if err := p.ensureGate(); err != nil {
    if strings.Contains(err.Error(), "创建 Anubis 验证提交请求失败") {
        // configuration bug: fail fast, do not retry
    }
    return err
}

Prevention

When it happens

Trigger: http.NewRequestWithContext fails — practically only when baseURL+anubisPassPath is not a parseable URL or the query encoding produces an invalid URL; ctx is nil.

Common situations: A misconfigured baseURL constant (empty string, missing scheme, embedded spaces/newline) breaking url.Parse; an empty anubisPassPath making the URL invalid in some builds.

Understand the failure class

Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.

Related errors


AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07). Data as JSON: /api/errors/bd218fd041283b23. Report an issue: GitHub.

Appendix: source

Thrown at plugin/miosou/miosou.go:198

	startedAt := time.Now()
	hash, nonce, err := solveAnubisChallenge(ctx, challenge.Challenge.RandomData, challenge.Rules.Difficulty)
	if err != nil {
		return err
	}
	elapsed := time.Since(startedAt).Milliseconds()
	if elapsed < 1 {
		elapsed = 1
	}
	query := url.Values{
		"id":          []string{challenge.Challenge.ID},
		"response":    []string{hash},
		"nonce":       []string{strconv.FormatUint(nonce, 10)},
		"redir":       []string{baseURL + "/"},
		"elapsedTime": []string{strconv.FormatInt(elapsed, 10)},
	}
	passReq, err := http.NewRequestWithContext(ctx, http.MethodGet, baseURL+anubisPassPath+"?"+query.Encode(), nil)
	if err != nil {
		return fmt.Errorf("创建 Anubis 验证提交请求失败: %w", err)
	}
	setPageHeaders(passReq)
	passReq.Header.Set("Referer", resp.Request.URL.String())
	passResp, err := p.client.Do(passReq)
	if err != nil {
		return fmt.Errorf("提交 Anubis 验证结果失败: %w", err)
	}
	io.Copy(io.Discard, io.LimitReader(passResp.Body, 1<<20))
	passResp.Body.Close()
	if passResp.StatusCode != http.StatusOK || isAnubisGateResponse(passResp) {
		return fmt.Errorf("Anubis 验证结果返回状态码 %d", passResp.StatusCode)
	}
	return nil
}

func (p *MiosouPlugin) invalidateGate() {
	p.gateMu.Lock()
	p.gateReady = false

View on GitHub (pinned to beaa561337)