{"record":{"id":"257e942cc8911e9e","repo":"larksuite/cli","slug":"app-registration-failed-s","errorCode":null,"errorMessage":"app registration failed: %s","messagePattern":"app registration failed: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/auth/app_registration.go","lineNumber":140,"sourceCode":"\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"app registration failed: read body: %w\", err)\n\t}\n\n\tvar data map[string]interface{}\n\tif err := json.Unmarshal(body, &data); err != nil {\n\t\treturn nil, fmt.Errorf(\"app registration failed: HTTP %d – response not JSON\", resp.StatusCode)\n\t}\n\n\t_, hasError := data[\"error\"]\n\tif resp.StatusCode >= 400 || hasError {\n\t\tmsg := getStr(data, \"error_description\")\n\t\tif msg == \"\" {\n\t\t\tmsg = getStr(data, \"error\")\n\t\t}\n\t\tif msg == \"\" {\n\t\t\tmsg = \"Unknown error\"\n\t\t}\n\t\treturn nil, fmt.Errorf(\"app registration failed: %s\", msg)\n\t}\n\n\t// The protocol field is expire_in; accept the legacy expires_in spelling,\n\t// then normalize to protocol defaults.\n\texpiresIn := getInt(data, \"expire_in\", 0)\n\tif expiresIn <= 0 {\n\t\texpiresIn = getInt(data, \"expires_in\", 0)\n\t}\n\texpiresIn = normalizedExpireIn(expiresIn)\n\tinterval := normalizedInterval(getInt(data, \"interval\", 0))\n\n\tdeviceCode := getStr(data, \"device_code\")\n\tif deviceCode == \"\" {\n\t\treturn nil, fmt.Errorf(\"app registration failed: response missing device_code\")\n\t}\n\n\tuserCode := getStr(data, \"user_code\")\n\tverificationUri := getStr(data, \"verification_uri\")","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/auth/app_registration.go#L122-L158","documentation":"Thrown by RequestAppRegistration at internal/auth/app_registration.go:140 when the begin response either has HTTP status >= 400 or contains an \"error\" field. The message carries the server's error_description (falling back to error, then 'Unknown error'). This is the library's generic surfaced server-side rejection of the registration initiation.","triggerScenarios":"Server responds 4xx/5xx (rate limit, bad request, unauthorized origin) or returns 200 with an OAuth-style error object such as {\"error\":\"...\"} during the 'begin' action of device registration.","commonSituations":"Server-side rate limiting after repeated registration attempts; blocked region or IP; deprecated/retired registration endpoint returning an error payload; service outage reporting errors in-band.","solutions":["Read the %s text in the message — it is the server's error_description; fix the condition it names.","If rate-limited, wait and retry after the indicated backoff period.","Verify network region: some corporate egress IPs are blocked by the accounts service.","Update the CLI — an outdated protocol request (archetype/auth_method fields) can be rejected by newer servers.","If the message is 'Unknown error', capture logs (logHTTPResponse output) and report the issue with the HTTP status."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"resp, err := RequestAppRegistration(ctx, client, brand, errOut)\nif err != nil {\n    var msg string\n    if _, after, ok := strings.Cut(err.Error(), \"app registration failed: \"); ok {\n        msg = after // server-provided error_description; surface to the user\n    }\n    return fmt.Errorf(\"registration begin rejected: %s\", msg)\n}","preventionTips":["Rate-limit your own retries of the registration flow.","Keep the CLI updated so begin-request protocol fields stay accepted.","Register from an unblocked network region/IP."],"tags":["http","server-error","device-flow","oauth"],"backgroundTag":"oauth-provider-error","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"}