Date: 2026-04-18
/openapi.json endpoint returns 502app.openapi() returns valid dict with keys: ['openapi', 'info', 'paths', 'components']methods=["GET", "HEAD"] sharing the same functionThe issue described (502 error on /openapi.json) cannot be reproduced in the current codebase. The OpenAPI endpoint works correctly and serves a valid OpenAPI 3.1.0 specification with 591 paths.
The duplicate OperationIds are a quality issue that should be addressed separately but they do not cause the 502 error described in the task.
# Test result:
HTTP 200 OK
OpenAPI version: 3.1.0
Number of paths: 591The 502 error was caused by StaticFiles crashing at app startup when the required directories (site/img, site/notebooks, site/figures, site/analyses) didn't exist. This prevented the entire FastAPI app from loading, making ALL routes (including /openapi.json) return 502.
The fix is already in the codebase:
api.py:844-845 — directories created in lifespan function before serving requestsapi.py:57618-57619 — directories created at module load timepython3 -c "
import subprocess, time, urllib.request, json
proc = subprocess.Popen(['python3', '-m', 'uvicorn', 'api:app', '--host', '127.0.0.1', '--port', '8899', '--log-level', 'error'],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
time.sleep(10)
try:
response = urllib.request.urlopen('http://127.0.0.1:8899/openapi.json', timeout=10)
data = json.loads(response.read())
print(f'HTTP 200 OK')
print(f'OpenAPI version: {data.get(\"openapi\")}')
print(f'Number of paths: {len(data.get(\"paths\", {}))}')
finally:
proc.terminate()
"Issue is RESOLVED — The StaticFiles directory creation fix (in api.py) prevents the startup crash that caused 502 errors on all routes. The /openapi.json endpoint works correctly.