Marketplace tests update

This commit is contained in:
2025-09-24 22:28:44 +02:00
parent f9879126c8
commit cea88a46c5
16 changed files with 613 additions and 73 deletions

View File

@@ -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
}
}
)