Marketplace tests update
This commit is contained in:
@@ -85,6 +85,24 @@ def setup_exception_handlers(app):
|
||||
}
|
||||
)
|
||||
|
||||
# Clean up validation errors to ensure JSON serializability
|
||||
clean_errors = []
|
||||
for error in exc.errors():
|
||||
clean_error = {}
|
||||
for key, value in error.items():
|
||||
if key == 'ctx' and isinstance(value, dict):
|
||||
# Handle the 'ctx' field that contains ValueError objects
|
||||
clean_ctx = {}
|
||||
for ctx_key, ctx_value in value.items():
|
||||
if isinstance(ctx_value, Exception):
|
||||
clean_ctx[ctx_key] = str(ctx_value) # Convert exception to string
|
||||
else:
|
||||
clean_ctx[ctx_key] = ctx_value
|
||||
clean_error[key] = clean_ctx
|
||||
else:
|
||||
clean_error[key] = value
|
||||
clean_errors.append(clean_error)
|
||||
|
||||
return JSONResponse(
|
||||
status_code=422,
|
||||
content={
|
||||
@@ -92,7 +110,7 @@ def setup_exception_handlers(app):
|
||||
"message": "Request validation failed",
|
||||
"status_code": 422,
|
||||
"details": {
|
||||
"validation_errors": exc.errors()
|
||||
"validation_errors": clean_errors # Use cleaned errors
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user