Skip to content

Debugging

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 category
  • loc — where the error occurred (["path", "body", "query", "header"])
  • msg — human-readable message
  • input — the value that was rejected
app = JustAPIApp(debug=True)

Debug mode enables detailed tracebacks in responses.

Never use debug=True in production. It exposes internal details.

@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.

GET /nonexistent returns 404 with no body.

Fix: Check your route path and method.

POST /items when only @app.get("/items") is defined returns 405.

Fix: Add the missing HTTP method decorator.

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": []}