{"record":{"id":"0d6d4efc87c4919f","repo":"bytedance/deer-flow","slug":"str-e-0d6d4e","errorCode":null,"errorMessage":"str(e)","messagePattern":"str\\(e\\)","errorType":"http","errorClass":"HTTPException","httpStatus":504,"severity":"error","filePath":"backend/app/gateway/routers/integrations.py","lineNumber":301,"sourceCode":"        logger.error(\"Failed to install Lark integration: %s\", e, exc_info=True)\n        raise HTTPException(status_code=500, detail=\"Failed to install Lark integration.\")\n\n\n@router.post(\"/lark/config/start\", response_model=LarkConfigStartResponse, summary=\"Start Lark/Feishu App Configuration\")\nasync def start_lark_app_config(body: LarkConfigStartRequest) -> LarkConfigStartResponse:\n    try:\n        result = await asyncio.to_thread(\n            start_lark_config,\n            get_effective_user_id(),\n            brand=body.brand,\n        )\n        return _config_start_to_response(result)\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))\n    except TimeoutError as e:\n        raise HTTPException(status_code=504, detail=str(e))\n    except Exception as e:\n        logger.error(\"Failed to start Lark connection setup: %s\", e, exc_info=True)\n        raise HTTPException(status_code=500, detail=\"Failed to start Lark connection setup.\")\n\n\n@router.post(\"/lark/config/complete\", response_model=LarkConfigCompleteResponse, summary=\"Complete Lark/Feishu App Configuration\")\nasync def complete_lark_app_config(request: Request, body: LarkConfigCompleteRequest, config: AppConfig = Depends(get_config)) -> LarkConfigCompleteResponse:\n    try:\n        result = await asyncio.to_thread(\n            complete_lark_config,\n            get_effective_user_id(),\n            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        )","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/app/gateway/routers/integrations.py#L283-L319","documentation":"504 from POST /lark/config/start when start_lark_config raises TimeoutError. The begin step is a blocking urllib POST to https://accounts.feishu.cn (via _post_lark_form / _request_lark_app_registration_begin); a socket-level timeout surfaces here. detail=str(e) carries the underlying timeout text.","triggerScenarios":"The Gateway cannot reach accounts.feishu.cn within the urllib timeout: blocked egress, DNS failure resolved slowly, or an intermediate proxy stalling the connection. Also the file-lock path _replace/save timeouts are not in this endpoint, so network is the realistic cause.","commonSituations":"Gateway containers without outbound internet, DNS misconfiguration in Docker, firewall allowing only specific domains, Feishu accounts endpoint being slow during outages.","solutions":["From the Gateway container, verify reachability: curl -m 10 https://accounts.feishu.cn","Fix egress rules/DNS so the Gateway can reach *.feishu.cn (and *.larksuite.com for lark brand)","Retry after network is fixed; no state was persisted by the failed start","If behind a proxy, configure it for the Gateway process (HTTP_PROXY/HTTPS_PROXY)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"await api.post('/integrations/healthcheck', {}, { timeout: 3000 }); // or ping accounts.feishu.cn from ops tooling","typeGuard":null,"tryCatchPattern":"try { ... } catch (e) {\n  if (e?.response?.status === 504) { await delay(5000); retryOnce(); }\n}","preventionTips":["Ensure Gateway egress to *.feishu.cn before deploying Lark integrations","Use exponential backoff with a single retry for 504 on start endpoints"],"tags":["lark","feishu","http-504","network","egress","timeout"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}