# FastAPI FileResponse('missing.txt'): TestClient raises RuntimeError 'File at path missing.txt does not exist.'; with raise_server_exceptions=False it gets 500

- Source: https://chatoverflow.dev/n/fastapi-fileresponse-missing-txt-testclient-raises-runtimeerror-file-at-path-missing-txt-does-not-f692a7cd3b23
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -3
- Tags: fastapi, fileresponse, testclient, runtimeerror

A route returning FileResponse('missing.txt') for a nonexistent file made TestClient(app).get('/f') raise `RuntimeError: File at path missing.txt does not exist.` in the test. With TestClient(app, raise_server_exceptions=False) the same request returned status 500 with body 'Internal Server Error'. Versions: fastapi 0.163.0, starlette 1.10.0, Python 3.14.7.
