7,294 questions
Score of -4
0 answers
149 views
Problems with getting variables via lifespan context manager in Fastapi [closed]
I wanna get variables created previously via lifespan for getting it in other part of my fastapi app.
Each variable is sqlalchemy session maker binded with sqlalchemy engine. So I`m using sub context ...
Score of 3
1 answer
93 views
How can I prevent duplicate Celery tasks when a FastAPI endpoint is retried?
I'm using FastAPI + Celery + Redis + PostgreSQL for a document-processing workflow.
A FastAPI endpoint creates a processing job and then sends a Celery task:
@app.post("/reports/{report_id}/...
Score of 0
1 answer
104 views
FastAPI Form() with List[Type] sends array as comma-separated string ("2,5") causing 422 parsing error in Swagger UI
Here's a Minimal, Reproducible Example:
from fastapi import FastAPI, Form
from typing import Annotated, List
app = FastAPI()
@app.post('/')
def create(arr: Annotated[List[int], Form()] = []):
...
Score of -5
1 answer
108 views
An error during using my FastAPI app. ValueError: [TypeError('object is not iterable'), TypeError('vars() argument must have __dict__ attribute')]
I'm trying to make my FastAPI app for using my trained ML-model, but I get this error
ValueError: [TypeError('object is not iterable'), TypeError('vars()
argument must have __dict__ attribute')]
...
Score of -3
1 answer
109 views
How to extend FastAPI's OAuth2PasswordBearer logout feature?
I'm using FastAPI for my backend and I already have /login and /logout endpoints for my frontend to talk to and I'm also using fastapi's OAuth2PasswordBearer (that points to a debug endpoint) to use ...
Score of -3
2 answers
146 views
How to solve the problem with None async engine in sqlalchemy before closing engine?
I have simple backend async application on fastapi and sqlalchemy.
Here code of my application:
main.py:
import uvicorn
import asyncio
from fastapi import FastAPI
from src.web.main_web_handler import ...
Score of 0
1 answer
164 views
FastAPI event loop blocked by Scikit-Learn Joblib thread-pool exhaustion during concurrent async inference
I am deploying a Random Forest model using FastAPI. Because Scikit-Learn models are synchronous and CPU-bound, I am offloading the inference to asyncio.get_running_loop().run_in_executor() to prevent ...
Score of 3
1 answer
212 views
FastAPI returning "Out of range float values are not JSON compliant" with Pandas NaN values
I am building a FastAPI endpoint that reads data, processes it into a Pandas DataFrame, and returns it as a JSON response.
However, my dataset contains missing data (NaN). When I convert the DataFrame ...
Score of -2
2 answers
129 views
What is a scalable alternative to embedding-based skill canonicalization in an ATS system [closed]
I am building an Applicant Tracking System (ATS) where candidates upload resumes and recruiters post job descriptions. The goal is to match candidates to relevant jobs.
Currently, my matching engine ...
Score of 0
2 answers
116 views
About the Pythonic code on FastAPI and Flask back end
I've done some jobs with the FastAPI or Flask on the backend, but in both situations there was no type of layering of the responsabilities. Like everything was done into the controller layer right ...
Score of 1
0 answers
125 views
How to correctly compare two encoded jwt refresh tokens
I using jwt in fastpai app, and when I create access and refresh tokens on user login I also create user session for specific user id in database, so as I understood I need to encrypt refresh token ...
Score of -1
1 answer
69 views
FastAPI returns 422 Unprocessable Entity on POST from Next.js fetch despite matching Pydantic model [duplicate]
I'm sending a POST request from a Next.js 14 client to a FastAPI endpoint. The request body matches my Pydantic model exactly, but I keep getting a 422 Unprocessable Entity instead of a 200.
Expected: ...
Score of 0
1 answer
100 views
FastAPI StreamingResponse buffers LLM tokens until completion when consumed by Next.js fetch. How can I fix this? [duplicate]
I am building an AI chat feature with a Next.js frontend and a FastAPI backend.
The backend receives tokens from an LLM provider and returns them to the browser using StreamingResponse. My goal is for ...
Score of 0
1 answer
176 views
FastAPI Controller/Service/Repo architecture routing with dependency injection
I'm mostly a C# and React dev working on a new project using Python with FastAPI to build the back-end for a tool.
I originally had logic like this in my `main.py` for setting up the fastapi app:
...
Score of 0
0 answers
112 views
FastAPI + Azure Functions -> intermittent 401 Unauthorized
I have an Azure Function (with a Flex Consumption plan) using FastAPI, and it has been working well for the last month.
Recently (starting last week), without any apparent reason, we started getting ...