feat: Add traceback to fastapi exception handler logs (#4099)
Add traceback to fastapi exception handler logs
This commit is contained in:
parent
d223eccdcc
commit
8516f31d58
7 changed files with 2 additions and 18 deletions
|
|
@ -76,7 +76,6 @@ async def get_all(
|
|||
)
|
||||
|
||||
except Exception as exc:
|
||||
logger.exception(exc)
|
||||
raise HTTPException(status_code=500, detail=str(exc)) from exc
|
||||
|
||||
|
||||
|
|
@ -277,13 +276,10 @@ async def simplified_run_flow(
|
|||
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=str(exc)) from exc
|
||||
if "not found" in str(exc):
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=str(exc)) from exc
|
||||
logger.exception(exc)
|
||||
raise APIException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, exception=exc, flow=flow) from exc
|
||||
except InvalidChatInputException as exc:
|
||||
logger.exception(exc)
|
||||
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=str(exc)) from exc
|
||||
except Exception as exc:
|
||||
logger.exception(exc)
|
||||
background_tasks.add_task(
|
||||
telemetry_service.log_package_run,
|
||||
RunPayload(
|
||||
|
|
@ -371,7 +367,6 @@ async def webhook_run_flow(
|
|||
)
|
||||
if "Flow ID is required" in str(exc) or "Request body is empty" in str(exc):
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
logger.exception(exc)
|
||||
raise HTTPException(status_code=500, detail=str(exc)) from exc
|
||||
|
||||
|
||||
|
|
@ -486,10 +481,8 @@ async def experimental_run_flow(
|
|||
if f"Session {session_id} not found" in str(exc):
|
||||
logger.exception(f"Session {session_id} not found")
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=str(exc)) from exc
|
||||
logger.exception(exc)
|
||||
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(exc)) from exc
|
||||
except Exception as exc:
|
||||
logger.exception(exc)
|
||||
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(exc)) from exc
|
||||
|
||||
|
||||
|
|
@ -650,7 +643,6 @@ async def custom_component_update(
|
|||
|
||||
return component_node
|
||||
except Exception as exc:
|
||||
logger.exception(exc)
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
||||
|
||||
|
|
@ -662,5 +654,4 @@ def get_config():
|
|||
settings_service: SettingsService = get_settings_service()
|
||||
return settings_service.settings.model_dump()
|
||||
except Exception as exc:
|
||||
logger.exception(exc)
|
||||
raise HTTPException(status_code=500, detail=str(exc)) from exc
|
||||
|
|
|
|||
|
|
@ -358,7 +358,6 @@ async def delete_multiple_flows(
|
|||
db.commit()
|
||||
return {"deleted": len(flows_to_delete)}
|
||||
except Exception as exc:
|
||||
logger.exception(exc)
|
||||
raise HTTPException(status_code=500, detail=str(exc)) from exc
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from loguru import logger
|
||||
|
||||
from langflow.graph.graph.schema import GraphDump
|
||||
from langflow.services.auth.utils import get_current_active_user
|
||||
|
|
@ -19,5 +18,4 @@ def get_starter_projects(
|
|||
try:
|
||||
return get_starter_projects_dump()
|
||||
except Exception as exc:
|
||||
logger.exception(exc)
|
||||
raise HTTPException(status_code=500, detail=str(exc)) from exc
|
||||
|
|
|
|||
|
|
@ -44,5 +44,4 @@ def post_validate_prompt(prompt_request: ValidatePromptRequest):
|
|||
frontend_node=prompt_request.frontend_node,
|
||||
)
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
raise HTTPException(status_code=500, detail=str(e)) from e
|
||||
|
|
|
|||
|
|
@ -174,7 +174,6 @@ def add_new_variables_to_template(input_variables, custom_fields, template, name
|
|||
custom_fields[name].append(variable)
|
||||
|
||||
except Exception as exc:
|
||||
logger.exception(exc)
|
||||
raise HTTPException(status_code=500, detail=str(exc)) from exc
|
||||
|
||||
|
||||
|
|
@ -190,7 +189,6 @@ def remove_old_variables_from_template(old_custom_fields, input_variables, custo
|
|||
template.pop(variable, None)
|
||||
|
||||
except Exception as exc:
|
||||
logger.exception(exc)
|
||||
raise HTTPException(status_code=500, detail=str(exc)) from exc
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1035,7 +1035,6 @@ class Graph:
|
|||
except KeyError as exc:
|
||||
logger.exception(exc)
|
||||
if "nodes" not in payload and "edges" not in payload:
|
||||
logger.exception(exc)
|
||||
msg = f"Invalid payload. Expected keys 'nodes' and 'edges'. Found {list(payload.keys())}"
|
||||
raise ValueError(msg) from exc
|
||||
|
||||
|
|
|
|||
|
|
@ -208,12 +208,12 @@ def create_app():
|
|||
@app.exception_handler(Exception)
|
||||
async def exception_handler(request: Request, exc: Exception):
|
||||
if isinstance(exc, HTTPException):
|
||||
logger.error(f"HTTPException: {exc.detail}")
|
||||
logger.error(f"HTTPException: {exc}", exc_info=exc)
|
||||
return JSONResponse(
|
||||
status_code=exc.status_code,
|
||||
content={"message": str(exc.detail)},
|
||||
)
|
||||
logger.error(f"unhandled error: {exc}")
|
||||
logger.error(f"unhandled error: {exc}", exc_info=exc)
|
||||
return JSONResponse(
|
||||
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
||||
content={"message": str(exc)},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue