{"record":{"id":"ba6ae3d2ae881c9b","repo":"bytedance/deer-flow","slug":"failed-to-complete-lark-connection-setup","errorCode":null,"errorMessage":"Failed to complete Lark connection setup.","messagePattern":"Failed to complete Lark connection setup\\.","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"backend/app/gateway/routers/integrations.py","lineNumber":331,"sourceCode":"            config,\n            device_code=body.device_code,\n            generation=body.generation,\n            brand=body.brand,\n            interval=body.interval,\n            expires_in=body.expires_in,\n        )\n        return _config_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 connection setup: %s\", e, exc_info=True)\n        raise HTTPException(status_code=500, detail=\"Failed to complete Lark connection setup.\")\n\n\n@router.post(\"/lark/config/credentials\", response_model=LarkConfigCompleteResponse, summary=\"Switch Lark/Feishu App Credentials\")\nasync def switch_lark_app_credentials(request: Request, body: LarkConfigCredentialsRequest, config: AppConfig = Depends(get_config)) -> LarkConfigCompleteResponse:\n    try:\n        result = await asyncio.to_thread(\n            set_lark_app_credentials,\n            get_effective_user_id(),\n            config,\n            app_id=body.app_id,\n            app_secret=body.app_secret,\n            brand=body.brand,\n        )\n        return _config_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 ValueError as e:\n        raise HTTPException(status_code=400, detail=str(e))","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/app/gateway/routers/integrations.py#L313-L349","documentation":"Generic 500 catch-all for POST /lark/config/complete (integrations.py:331). Exceptions from complete_lark_config outside FileNotFoundError/LarkFlowSupersededError/ValueError/TimeoutError — e.g. OSError writing credential files, JSON errors, or unexpected status-probe failures in get_lark_integration_status — are logged with traceback and returned opaquely.","triggerScenarios":"Credential file write fails (disk full, permissions) inside _replace_lark_app_credentials_locked; status verification crashing after successful registration.","commonSituations":"Read-only volumes for the credential tree, container user lacking write perms, disk exhaustion on the Gateway host.","solutions":["Inspect the 'Failed to complete Lark connection setup:' traceback in Gateway logs","Verify the per-user Lark credential/state directory is writable by the Gateway process","Retry complete with the same device_code/generation if the flow was not superseded; otherwise restart the flow"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await complete(); } catch (e) {\n  if (e?.response?.status === 500) { const st = await api.get('/integrations/lark/status'); report(st.data); }\n}","preventionTips":["Keep the credential directory writable by the Gateway user","After any 500, reconcile state via GET /lark/status before retrying"],"tags":["lark","feishu","http-500","gateway","filesystem","credentials"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}