Debugging
Error Messages
Section titled “Error Messages”JustAPI returns structured error responses for validation failures:
{ "detail": [ { "type": "int_parsing", "loc": ["path", "item_id"], "msg": "Input should be a valid integer", "input": "foo" } ]}The detail array contains every validation error with:
type— error categoryloc— where the error occurred (["path", "body", "query", "header"])msg— human-readable messageinput— the value that was rejected
Debug Mode
Section titled “Debug Mode”app = JustAPIApp(debug=True)Debug mode enables detailed tracebacks in responses.
Never use debug=True in production. It exposes internal details.
Common Errors
Section titled “Common Errors”422 Validation Error
Section titled “422 Validation Error”@app.get("/items/{item_id}")def get_item(item_id: int): return {"item_id": item_id}GET /items/foo returns 422 because "foo" is not a valid int.
Fix: Ensure the URL value matches the declared type.
404 Not Found
Section titled “404 Not Found”GET /nonexistent returns 404 with no body.
Fix: Check your route path and method.
405 Method Not Allowed
Section titled “405 Method Not Allowed”POST /items when only @app.get("/items") is defined returns 405.
Fix: Add the missing HTTP method decorator.
Logging
Section titled “Logging”Use standard Python logging with JustAPI:
import logging
logging.basicConfig(level=logging.INFO)logger = logging.getLogger(__name__)
@app.get("/items")def list_items(): logger.info("Listing items") return {"items": []}See Also
Section titled “See Also”- Testing — automated tests
- Error Codes — complete error code reference
- Security Policy — reporting security issues