Return clear node-missing JSON and reset Web UI auth on 401.

Keep Ingress from rewriting API 404/405 into branded HTML; document curl/auth and a prompt for sibling sims.
This commit is contained in:
Sergey Antropoff
2026-07-22 06:52:45 +03:00
parent baa1f58ad0
commit f981ca1bf1
9 changed files with 219 additions and 7 deletions
+15 -3
View File
@@ -76,7 +76,11 @@ async def require_node(request: Request, node: str) -> None:
node,
)
if not exists:
raise ApiError(404, "node does not exist")
raise ApiError(
404,
f"No such node ('{node}')",
errors={"node": f"No such node ('{node}')"},
)
async def cluster_metadata(request: Request) -> dict[str, Any]:
@@ -105,7 +109,11 @@ async def node_metadata(request: Request, node: str) -> dict[str, Any]:
node,
)
if row is None:
raise ApiError(404, "node does not exist")
raise ApiError(
404,
f"No such node ('{node}')",
errors={"node": f"No such node ('{node}')"},
)
return state(row["metadata"])
@@ -116,7 +124,11 @@ async def save_node_metadata(request: Request, node: str, metadata: dict[str, An
json.dumps(metadata, sort_keys=True),
)
if status != "UPDATE 1":
raise ApiError(404, "node does not exist")
raise ApiError(
404,
f"No such node ('{node}')",
errors={"node": f"No such node ('{node}')"},
)
def storage_payload(row: Any) -> dict[str, Any]:
+20 -3
View File
@@ -4822,6 +4822,7 @@
state.ticket = null;
state.csrf = null;
state.username = null;
document.cookie = "PVEAuthCookie=; Max-Age=0; path=/; SameSite=Strict";
localStorage.removeItem(LS_AUTH);
setAuth(false);
}
@@ -6019,16 +6020,29 @@
}
}
function logout() {
function clearSession(options = {}) {
const { toastMessage = null, toastKind = "info", closePanel = true } = options;
state.ticket = null;
state.csrf = null;
state.username = null;
document.cookie = "PVEAuthCookie=; Max-Age=0; path=/; SameSite=Strict";
setAuth(false);
persistAuth();
closeAuthPanel();
if (closePanel) closeAuthPanel();
resetClusterStats("—");
toast("Signed out", "info");
if (toastMessage) toast(toastMessage, toastKind);
}
function logout() {
clearSession({ toastMessage: "Signed out", toastKind: "info" });
}
function expireSession() {
clearSession({
toastMessage: "Session expired — sign in again",
toastKind: "warn",
closePanel: false,
});
}
function updateStatusBadge(status) {
@@ -6101,6 +6115,9 @@
const text = await res.text();
let parsed;
try { parsed = JSON.parse(text); } catch { parsed = text; }
if (res.status === 401 && (state.ticket || state.username)) {
expireSession();
}
return { status: res.status, body: parsed, durationMs: Math.round(performance.now() - started) };
}