Code Room
Vibe codingHard
Question
An AI built this FastAPI file-upload handler that hashes and stores avatars. Throughput is far below expectations and the event loop's lag metric is high even though each request is small. Identify the blocking calls and the right fix for each.
import hashlib, time @app.post("/avatar")async def upload_avatar(file: UploadFile): data = file.file.read() # sync file read digest = hashlib.sha256(data).hexdigest() # CPU work time.sleep(0.05) # 'rate limit' the writer with open(f"/data/{digest}.png", "wb") as f: f.write(data) # sync disk write return {"hash": digest}What a strong answer looks like
Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.
Learn the concepts
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.
Run or narrate your approach, then ask the coach.