bytedance/deer-flow · error · HTTPException

Failed to switch Lark app credentials.

Error message

Failed to switch Lark app credentials.

What it means

Generic 500 catch-all for POST /lark/config/credentials (integrations.py:354). Unexpected exceptions from set_lark_app_credentials — CLI subprocess OS errors, unexpected JSON, crashes writing credential files — are logged with traceback and surfaced as this opaque 500.

Source

Thrown at backend/app/gateway/routers/integrations.py:354

    try:
        result = await asyncio.to_thread(
            set_lark_app_credentials,
            get_effective_user_id(),
            config,
            app_id=body.app_id,
            app_secret=body.app_secret,
            brand=body.brand,
        )
        return _config_complete_to_response(result, include_host_paths=await _is_admin_user(request))
    except FileNotFoundError as e:
        raise HTTPException(status_code=404, detail=str(e))
    except ValueError as e:
        raise HTTPException(status_code=400, detail=str(e))
    except TimeoutError as e:
        raise HTTPException(status_code=504, detail=str(e))
    except Exception as e:
        logger.error("Failed to switch Lark app credentials: %s", e, exc_info=True)
        raise HTTPException(status_code=500, detail="Failed to switch Lark app credentials.")


@router.post("/lark/auth/start", response_model=LarkAuthStartResponse, summary="Start Lark/Feishu Browser Authorization")
async def start_lark_browser_auth(body: LarkAuthStartRequest) -> LarkAuthStartResponse:
    try:
        result = await asyncio.to_thread(
            start_lark_auth,
            get_effective_user_id(),
            domains=tuple(body.domains),
            scope=body.scope,
            recommend=body.recommend,
            generation=body.generation,
        )
        return _auth_start_to_response(result)
    except FileNotFoundError as e:
        raise HTTPException(status_code=404, detail=str(e))
    except LarkFlowSupersededError as e:
        raise HTTPException(status_code=409, detail=str(e))

View on GitHub (pinned to 1dd6ba1acb)

Solutions

  1. Read the 'Failed to switch Lark app credentials:' traceback in Gateway logs
  2. Confirm the managed lark-cli binary executes: run it manually as the Gateway user
  3. Check GET /lark/status afterwards — the switch may have partially applied before the failure; retry only if status shows the old app
  4. Reinstall via POST /lark/install to repair a corrupt CLI
Defensive patterns

Strategy: try-catch

Try / catch

try { await switchCreds(body); } catch (e) {
  if (e?.response?.status === 500) { await api.get('/integrations/lark/status').then(report); }
}

Prevention

When it happens

Trigger: lark-cli binary present but failing to execute (permissions, exec format), credential file write OSError, status probe raising after the switch committed.

Common situations: Corrupt managed CLI install, architecture-mismatched binary, read-only credential directory.

Related errors


AI-assisted analysis of bytedance/deer-flow@1dd6ba1acb (2026-08-14). Data as JSON: /api/errors/885854e2e1d18fb9. Report an issue: GitHub.