larksuite/cli · error
poll request: %w
Error message
poll request: %w
What it means
Thrown by pollOnce at internal/auth/app_registration.go:190 when http.NewRequestWithContext fails while constructing the 'poll' request for the device-flow registration endpoint. This is a local request-construction error, not a network error; the cause (e.g. unsupported method or unparsable URL) is wrapped via %w.
Source
Thrown at internal/auth/app_registration.go:190
func BuildVerificationURL(baseURL, cliVersion string) string {
sep := "&"
if !strings.Contains(baseURL, "?") {
sep = "?"
}
return baseURL + sep + "lpv=" + url.QueryEscape(cliVersion) +
"&ocv=" + url.QueryEscape(cliVersion) +
"&from=cli"
}
// pollOnce performs one ctx-bound poll request and decodes the payload.
func pollOnce(ctx context.Context, httpClient *http.Client, brand core.LarkBrand, deviceCode string) (map[string]interface{}, error) {
form := url.Values{}
form.Set("action", "poll")
form.Set("device_code", deviceCode)
req, err := http.NewRequestWithContext(ctx, "POST", appRegistrationEndpoint(brand), strings.NewReader(form.Encode()))
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)
}View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Inspect the wrapped cause in the error text to identify the malformed component.
- Verify endpoint configuration/resolution (internal/core.ResolveEndpoints) is returning a valid absolute URL.
- Update the CLI in case the embedded endpoint catalog is stale or corrupted.
- Retry the registration flow; if reproducible, report with the wrapped error detail.
Defensive patterns
Strategy: validation
Validate before calling
u, err := url.Parse(appRegistrationEndpoint(brand))
if err != nil || u.Scheme == "" || u.Host == "" {
return fmt.Errorf("invalid registration endpoint resolved for brand %v", brand)
} Try / catch
result, err := pollOnce(ctx, client, brand, deviceCode)
if err != nil {
if strings.Contains(err.Error(), "poll request:") {
return nil, fmt.Errorf("unrecoverable request construction failure: %w", err)
}
// otherwise treat as transient
} Prevention
- Never override the resolved endpoint catalog with hand-built URLs.
- Verify endpoint resolution config when embedding the library.
- Test brand endpoint resolution in CI.
When it happens
Trigger: Only when the request itself cannot be built: ctx is nil (which panics rather than errors, so in practice this is nearly unreachable), or the endpoint URL produced by appRegistrationEndpoint is malformed. Normal context cancellation surfaces later at httpClient.Do, not here.
Common situations: Effectively never hit in production since brand endpoints are resolved from a static catalog; would appear only if endpoint resolution (core.ResolveEndpoints) returned a corrupt/empty URL or in modified/embedded environments with a broken endpoint table.
Related errors
- app registration failed: HTTP %d – response not JSON
- app registration failed: %s
- poll network error: %w
- poll read error: %w
- poll parse error: %w
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/ed20ccf04db5074f.
Report an issue: GitHub.