fix: add validation logging and debug info for tool instance creation
- Add RequestValidationError handler to log validation errors - Add extra=ignore to CreateInstanceRequest to be more lenient - Add logging to create_instance endpoint to see received data - Add missing logger import in tool_instances.py
This commit is contained in:
+19
-1
@@ -1,8 +1,10 @@
|
||||
import logging
|
||||
import os
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.exceptions import RequestValidationError
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from sqlalchemy import select, text
|
||||
|
||||
@@ -48,6 +50,22 @@ app.add_middleware(RequestLoggingMiddleware)
|
||||
app.add_middleware(ExceptionLoggingMiddleware)
|
||||
|
||||
|
||||
@app.exception_handler(RequestValidationError)
|
||||
async def validation_exception_handler(request: Request, exc: RequestValidationError):
|
||||
"""Log validation errors and return detailed response."""
|
||||
errors = exc.errors()
|
||||
logger.warning(
|
||||
"Validation error for %s %s: %s",
|
||||
request.method,
|
||||
request.url.path,
|
||||
errors,
|
||||
)
|
||||
return JSONResponse(
|
||||
status_code=422,
|
||||
content={"detail": errors},
|
||||
)
|
||||
|
||||
|
||||
async def _table_exists(session, table_name: str) -> bool:
|
||||
"""Check if a table exists in the database."""
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user