{"record":{"id":"89c2b02ed580b022","repo":"bytedance/deer-flow","slug":"failed-to-complete-lark-authorization","errorCode":null,"errorMessage":"Failed to complete Lark authorization.","messagePattern":"Failed to complete Lark authorization\\.","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"backend/app/gateway/routers/integrations.py","lineNumber":404,"sourceCode":"            complete_lark_auth,\n            get_effective_user_id(),\n            config,\n            device_code=body.device_code,\n            generation=body.generation,\n            wait_timeout_seconds=body.wait_timeout_seconds,\n        )\n        return _auth_complete_to_response(result, include_host_paths=await _is_admin_user(request))\n    except FileNotFoundError as e:\n        raise HTTPException(status_code=404, detail=str(e))\n    except LarkFlowSupersededError as e:\n        raise HTTPException(status_code=409, detail=str(e))\n    except ValueError as e:\n        raise HTTPException(status_code=400, detail=str(e))\n    except TimeoutError as e:\n        raise HTTPException(status_code=504, detail=str(e))\n    except Exception as e:\n        logger.error(\"Failed to complete Lark authorization: %s\", e, exc_info=True)\n        raise HTTPException(status_code=500, detail=\"Failed to complete Lark authorization.\")\n","sourceCodeStart":386,"sourceCodeEnd":405,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/app/gateway/routers/integrations.py#L386-L405","documentation":"Generic 500 returned when complete_lark_auth raises an unexpected exception (anything outside FileNotFoundError/LarkFlowSupersededError/ValueError/TimeoutError). The original exception is logged server-side with a full traceback; the client intentionally gets only the static message, so no internal details leak.","triggerScenarios":"Lark/Feishu API returns an unexpected error shape during token exchange, the configured Lark app credentials (app_id/app_secret) are wrong or missing, network failures to the Lark open-platform, or bugs in the auth state serialization code.","commonSituations":"Misconfigured Lark integration in config.yaml (invalid app secret); Lark API outage or rate limiting; expired/revoked Feishu app credentials; disk-full or permission errors writing token state.","solutions":["Check the Gateway logs for the logged traceback ('Failed to complete Lark authorization') — it names the real cause","Verify the Lark integration credentials (app_id/app_secret) in config.yaml and that the app has the required scopes","Confirm network egress from the Gateway host to open.feishu.cn","If the traceback points to state-file corruption, clear the stale Lark auth state and restart the flow"],"exampleFix":"// client: distinguish real 500s from retryable waits\n// before\nif (!res.ok) throw new Error(await res.text());\n// after\nif (res.status === 500) { console.error('server-side failure; check Gateway logs'); await restartFlow(); } else if (!res.ok) throw new Error(await res.text());","handlingStrategy":"retry","validationCode":"null","typeGuard":"null","tryCatchPattern":"try { return await complete(body); } catch (e) { if (e.status === 500) { await delay(backoff(attempt++)); if (attempt <= 3) return completeFreshFlow(); } throw e; }","preventionTips":["Check Gateway logs first — the client-visible message is intentionally generic","Validate Lark app credentials in config.yaml before starting flows","Use bounded retries with fresh flow start; do not retry the identical failed request"],"tags":["lark","oauth","http-500","internal-error"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}