fix: use shutil.which to find uv in _trigger_rebuild; never 500 on rebuild failure

This commit is contained in:
Davide Scaini
2026-04-10 15:33:06 +02:00
parent 7088b94a87
commit 8d8b009a78
+13 -8
View File
@@ -11,6 +11,7 @@ from __future__ import annotations
import json import json
import re import re
import secrets import secrets
import shutil
import subprocess import subprocess
import time import time
from pathlib import Path from pathlib import Path
@@ -168,14 +169,18 @@ def _trigger_rebuild(handle: str) -> None:
return return
if not _VALID_HANDLE.match(handle): if not _VALID_HANDLE.match(handle):
return # safety: never pass untrusted strings to subprocess return # safety: never pass untrusted strings to subprocess
subprocess.Popen( uv = shutil.which("uv") or str(Path.home() / ".local" / "bin" / "uv")
["uv", "run", "bincio", "render", try:
"--data-dir", str(data_dir), subprocess.Popen(
"--site-dir", str(site_dir), [uv, "run", "bincio", "render",
"--handle", handle], "--data-dir", str(data_dir),
stdout=subprocess.DEVNULL, "--site-dir", str(site_dir),
stderr=subprocess.DEVNULL, "--handle", handle],
) stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
except Exception:
pass # rebuild failure must never 500 the calling endpoint
# ── Auth endpoints ──────────────────────────────────────────────────────────── # ── Auth endpoints ────────────────────────────────────────────────────────────