swadhinbiswas docs: build docs_site — restructure sidebar, create 37 new pages · 7/25/2026
98106de
89 lines · 1.9 KB
Raw Download

title: Debugging
description: Debug JustAPI applications with detailed error messages, logging, and common troubleshooting patterns.
keywords: [JustAPI, debugging, errors, logging, troubleshooting]

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

Debug Mode

app = JustAPIApp(debug=True)

Debug mode enables detailed tracebacks in responses.

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

Common Errors

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

GET /nonexistent returns 404 with no body.

Fix: Check your route path and method.

405 Method Not Allowed

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

Fix: Add the missing HTTP method decorator.

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