{"record":{"id":"ed20ccf04db5074f","repo":"larksuite/cli","slug":"poll-request-w","errorCode":null,"errorMessage":"poll request: %w","messagePattern":"poll request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/auth/app_registration.go","lineNumber":190,"sourceCode":"func BuildVerificationURL(baseURL, cliVersion string) string {\n\tsep := \"&\"\n\tif !strings.Contains(baseURL, \"?\") {\n\t\tsep = \"?\"\n\t}\n\treturn baseURL + sep + \"lpv=\" + url.QueryEscape(cliVersion) +\n\t\t\"&ocv=\" + url.QueryEscape(cliVersion) +\n\t\t\"&from=cli\"\n}\n\n// pollOnce performs one ctx-bound poll request and decodes the payload.\nfunc pollOnce(ctx context.Context, httpClient *http.Client, brand core.LarkBrand, deviceCode string) (map[string]interface{}, error) {\n\tform := url.Values{}\n\tform.Set(\"action\", \"poll\")\n\tform.Set(\"device_code\", deviceCode)\n\n\treq, err := http.NewRequestWithContext(ctx, \"POST\", appRegistrationEndpoint(brand), strings.NewReader(form.Encode()))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"poll request: %w\", err)\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\n\tresp, err := httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"poll network error: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\tlogHTTPResponse(resp)\n\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"poll read error: %w\", err)\n\t}\n\tvar data map[string]interface{}\n\tif err := json.Unmarshal(body, &data); err != nil {\n\t\treturn nil, fmt.Errorf(\"poll parse error: %w\", err)\n\t}","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/auth/app_registration.go#L172-L208","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"u, err := url.Parse(appRegistrationEndpoint(brand))\nif err != nil || u.Scheme == \"\" || u.Host == \"\" {\n    return fmt.Errorf(\"invalid registration endpoint resolved for brand %v\", brand)\n}","typeGuard":null,"tryCatchPattern":"result, err := pollOnce(ctx, client, brand, deviceCode)\nif err != nil {\n    if strings.Contains(err.Error(), \"poll request:\") {\n        return nil, fmt.Errorf(\"unrecoverable request construction failure: %w\", err)\n    }\n    // otherwise treat as transient\n}","preventionTips":["Never override the resolved endpoint catalog with hand-built URLs.","Verify endpoint resolution config when embedding the library.","Test brand endpoint resolution in CI."],"tags":["http","request-construction","device-flow","polling"],"backgroundTag":"invalid-request-url","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}