diff --git a/starpilot/system/the_galaxy/assets/components/tools/tuning.js b/starpilot/system/the_galaxy/assets/components/tools/tuning.js index 0246149bb..9d1469324 100644 --- a/starpilot/system/the_galaxy/assets/components/tools/tuning.js +++ b/starpilot/system/the_galaxy/assets/components/tools/tuning.js @@ -541,7 +541,11 @@ async function revertProfile() { state.runningAction = true try { const response = await fetch("/api/flm/trials/revert", { method: "POST" }) - const payload = await response.json() + const body = await response.text() + let payload + try { payload = body ? JSON.parse(body) : {} } catch (_) { + payload = { error: body.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim() } + } if (!response.ok) throw new Error(payload.error || "Failed to revert trial profile.") state.error = "" await fetchWorkspace() diff --git a/starpilot/system/the_galaxy/the_galaxy.py b/starpilot/system/the_galaxy/the_galaxy.py index 93328e652..2ab19d6b5 100644 --- a/starpilot/system/the_galaxy/the_galaxy.py +++ b/starpilot/system/the_galaxy/the_galaxy.py @@ -6093,6 +6093,8 @@ def setup(app): result = flm_workspace.revert_trial_profile() except FileNotFoundError: return jsonify({"error": "No active FLM trial snapshot was found."}), 404 + except Exception as error: + return jsonify({"error": f"{type(error).__name__}: {error}"}), 500 return jsonify(result), 200