www.infolytx.com

FastAPI - The Good, the Bad and the Ugly - Infolytx

5/13/2023Updated 2/23/2026

Excerpt

## The Bad ### 1. Crowded main file In FastAPI, everything is tied to the ``` FastAPI app ``` . So, your ``` main.py ``` file can very easily become very crowded. Here is an example. … ### 2. No singleton in Dependency Injection Dependency Injection in FastAPI does no support ``` singleton ``` instances, according to this Github thread, but it supports single instance for each HTTP request. You either have to create singleton classes yourself or use a different DI library. ## The Ugly ### Request Validation My worst experience while working with FastAPI was handling request validations. It uses validation from ``` Pydantic ``` , and there is, to my knowledge, no straight forward way to pass down a validation message from the point of validation to the response. You have make do with whatever message is passed down by

Source URL

https://www.infolytx.com/fast-api-gbu/

Related Pain Points