larksuite/cli · warning

poll parse error: %w

Error message

poll parse error: %w

What it means

Thrown by pollOnce at internal/auth/app_registration.go:207 when json.Unmarshal cannot parse the poll response body as a JSON object. RegisterAppWithDiscovery logs it as a warning, increases the poll interval, and continues, so a persistent parse failure ends as a registration timeout rather than this error.

Source

Thrown at internal/auth/app_registration.go:207

	if err != nil {
		return nil, fmt.Errorf("poll request: %w", err)
	}
	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

	resp, err := httpClient.Do(req)
	if err != nil {
		return nil, fmt.Errorf("poll network error: %w", err)
	}
	defer resp.Body.Close()
	logHTTPResponse(resp)

	body, err := io.ReadAll(resp.Body)
	if err != nil {
		return nil, fmt.Errorf("poll read error: %w", err)
	}
	var data map[string]interface{}
	if err := json.Unmarshal(body, &data); err != nil {
		return nil, fmt.Errorf("poll parse error: %w", err)
	}
	return data, nil
}

// RegisterAppWithDiscovery polls for credentials, mirroring the official SDK
// flow: the first poll and the (at most one) cross-brand switch are immediate,
// non-error responses without complete credentials keep polling, and one
// deadline from the begin expiry bounds all waits and in-flight requests.
// The returned brand is the one the credentials were issued on.
func RegisterAppWithDiscovery(ctx context.Context, httpClient *http.Client, resp *AppRegistrationResponse, errOut io.Writer) (*AppRegistrationResult, core.LarkBrand, error) {
	if errOut == nil {
		errOut = io.Discard
	}

	// Interval and expiry arrive normalized from begin-response parsing
	// (normalizedInterval floors them there); the loop trusts them as-is.
	interval := resp.Interval
	ctx, cancel := context.WithDeadline(ctx,

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Check the CLI log lines ('[WARN] app-registration: poll parse error: ...') and inspect the poll endpoint with curl from the same machine.
  2. Fix captive-portal/proxy interference or switch networks.
  3. If the server outage persists past the device-code expiry, restart registration once the service recovers.
  4. Report a protocol regression to maintainers if a CLI/server version mismatch is suspected (update the CLI first).
Defensive patterns

Strategy: retry

Try / catch

data, err := pollOnce(ctx, client, brand, deviceCode)
if err != nil {
    if strings.Contains(err.Error(), "poll parse error:") {
        // logged by the loop; poll again after backoff, escalate if persistent
    }
}
// The built-in loop already retries; detect ultimate failure via ErrRegistrationTimedOut.

Prevention

When it happens

Trigger: The poll endpoint returns non-JSON: HTML error/challenge page, empty body from a 5xx gateway response, plaintext proxy block page, or a protocol change returning a different content type.

Common situations: Captive portal or WAF interstitial appearing mid-flow; regional endpoint outage returning HTML 502 pages; middleboxes rewriting responses between the successful begin call and later polls.

Understand the failure class

Related errors


AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04). Data as JSON: /api/errors/4cb088293ebd47fb. Report an issue: GitHub.