{"record":{"id":"349e432bb5bf44a2","repo":"HKUDS/Vibe-Trading","slug":"feishu-lark-registration-did-not-return-a-device","errorCode":null,"errorMessage":"Feishu / Lark registration did not return a device_code","messagePattern":"Feishu / Lark registration did not return a device_code","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agent/src/channels/feishu.py","lineNumber":500,"sourceCode":"    if \"client_secret\" not in methods:\n        raise RuntimeError(\n            f\"Feishu / Lark registration does not support client_secret auth. \"\n            f\"Supported: {methods}\"\n        )\n\n\ndef _begin_registration(domain: str = \"feishu\") -> dict:\n    \"\"\"Start the device-code flow. Returns device_code, qr_url, interval, expire_in.\"\"\"\n    base_url = _accounts_base_url(domain)\n    res = _post_registration(base_url, {\n        \"action\": \"begin\",\n        \"archetype\": \"PersonalAgent\",\n        \"auth_method\": \"client_secret\",\n        \"request_user_info\": \"open_id\",\n    })\n    device_code = res.get(\"device_code\")\n    if not device_code:\n        raise RuntimeError(\"Feishu / Lark registration did not return a device_code\")\n    qr_url = res.get(\"verification_uri_complete\", \"\")\n    if not qr_url:\n        raise RuntimeError(\"Feishu / Lark registration did not return a login URL\")\n    return {\n        \"device_code\": device_code,\n        \"qr_url\": qr_url,\n        \"interval\": res.get(\"interval\") or 5,\n        \"expire_in\": res.get(\"expire_in\") or 600,\n    }\n\n\ndef _poll_registration(\n    *,\n    device_code: str,\n    interval: int,\n    expire_in: int,\n    domain: str = \"feishu\",\n) -> dict | None:","sourceCodeStart":482,"sourceCodeEnd":518,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/channels/feishu.py#L482-L518","documentation":"During QR registration the begin-step response must include a device_code used for polling; a missing/empty device_code means the registration server returned an unexpected payload, so registration cannot proceed and a RuntimeError is raised.","triggerScenarios":"Calling _begin_registration when the registration endpoint responds without device_code — API version change, malformed response, error body not surfaced as an exception, or rate-limit-style responses with a partial payload.","commonSituations":"Registration API contract changes on the server, intermittent proxy interference rewriting responses, or region endpoints with divergent behavior.","solutions":["Retry the QR login flow — transient malformed responses do occur","Verify domain and app credentials (bad creds can yield error bodies missing fields)","Enable HTTP logging of _post_registration responses to inspect the raw payload","If persistent, report upstream: the begin-registration contract appears violated"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for attempt in range(3):\n    try:\n        begin_registration(domain)\n        break\n    except RuntimeError as e:\n        if 'device_code' not in str(e) or attempt == 2: raise\n        time.sleep(2 ** attempt)","preventionTips":["Treat missing device_code as transient and retry","Log raw registration responses to diagnose contract changes","Verify domain and credentials first — bad auth can produce field-less error bodies"],"tags":["feishu","auth","registration","device-code"],"backgroundTag":"oauth-registration-invalid-response","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}