[PR #6207] [MERGED] fix(nodes): report probe heartbeat persistence failures #6169

Closed
opened 2026-11-02 04:06:50 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6207
Author: @n0ctal
Created: 8/12/2026
Status: ✅ Merged
Merged: 8/13/2026
Merged by: @MHSanaei

Base: main ← Head: codex/upstream-node-probe-persist-error


📝 Commits (2)

  • 22d3eac fix(nodes): report probe heartbeat persistence failures
  • 62db331 Merge branch 'main' into codex/upstream-node-probe-persist-error

📊 Changes

2 files changed (+53 additions, -1 deletions)

View changed files

📝 internal/web/controller/node.go (+4 -1)
📝 internal/web/controller/node_credentials_writeonly_test.go (+49 -0)

📄 Description

Summary

The manual node probe endpoint discards the error from UpdateHeartbeat, so the panel reports a successful probe even when the result was never stored. This propagates the error to the caller.

Why

probe contacts the node, builds a status patch, persists it, and returns the patch to the UI. The persistence result was dropped with _ =. When the write fails, the operator sees a green result and a node row that still shows the previous state; the next background heartbeat then reports something different, and the disagreement looks like flapping rather than a failed write.

The background heartbeat path already checks this same error. The controller was the one branch that did not, which is the usual sign of an oversight rather than a decision.

Scope

  • internal/web/controller/node.go: probe returns the persistence failure through jsonMsg instead of ignoring it.

The i18n key reused here, pages.nodes.toasts.test, is the one the surrounding handlers already use for this operation and is translated in every locale.

Validation

  • New test TestNodeControllerProbeReportsHeartbeatPersistenceFailure drives the real HTTP handler with a fake remote and an injected persistence failure.
  • Mutation-checked: with internal/web/controller/node.go reverted, the test fails with probe reported success despite heartbeat persistence failure, so it guards the defect rather than the signature.
  • go build ./internal/..., go vet, package tests, golangci-lint, staticcheck -checks=U1000 (host and GOOS=linux), make gen-check: all clean.

Risk

This changes what the endpoint returns in one case: a probe that reached the node but could not be recorded is now an error response rather than a success carrying the live result. That is the intended trade — the operator should not be told a node was checked when the check was not durable. Callers that only read the success flag will now surface a failure where they previously showed stale data.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6207 **Author:** [@n0ctal](https://github.com/n0ctal) **Created:** 8/12/2026 **Status:** ✅ Merged **Merged:** 8/13/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `codex/upstream-node-probe-persist-error` --- ### 📝 Commits (2) - [`22d3eac`](https://github.com/MHSanaei/3x-ui/commit/22d3eaccf5cc661d07930ddbabb19d9ccd3aa478) fix(nodes): report probe heartbeat persistence failures - [`62db331`](https://github.com/MHSanaei/3x-ui/commit/62db33129c7240e660efac6b68227aa5ca766166) Merge branch 'main' into codex/upstream-node-probe-persist-error ### 📊 Changes **2 files changed** (+53 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `internal/web/controller/node.go` (+4 -1) 📝 `internal/web/controller/node_credentials_writeonly_test.go` (+49 -0) </details> ### 📄 Description ## Summary The manual node probe endpoint discards the error from `UpdateHeartbeat`, so the panel reports a successful probe even when the result was never stored. This propagates the error to the caller. ## Why `probe` contacts the node, builds a status patch, persists it, and returns the patch to the UI. The persistence result was dropped with `_ =`. When the write fails, the operator sees a green result and a node row that still shows the previous state; the next background heartbeat then reports something different, and the disagreement looks like flapping rather than a failed write. The background heartbeat path already checks this same error. The controller was the one branch that did not, which is the usual sign of an oversight rather than a decision. ## Scope - `internal/web/controller/node.go`: `probe` returns the persistence failure through `jsonMsg` instead of ignoring it. The i18n key reused here, `pages.nodes.toasts.test`, is the one the surrounding handlers already use for this operation and is translated in every locale. ## Validation - New test `TestNodeControllerProbeReportsHeartbeatPersistenceFailure` drives the real HTTP handler with a fake remote and an injected persistence failure. - Mutation-checked: with `internal/web/controller/node.go` reverted, the test fails with `probe reported success despite heartbeat persistence failure`, so it guards the defect rather than the signature. - `go build ./internal/...`, `go vet`, package tests, `golangci-lint`, `staticcheck -checks=U1000` (host and `GOOS=linux`), `make gen-check`: all clean. ## Risk This changes what the endpoint returns in one case: a probe that reached the node but could not be recorded is now an error response rather than a success carrying the live result. That is the intended trade — the operator should not be told a node was checked when the check was not durable. Callers that only read the success flag will now surface a failure where they previously showed stale data. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:06:50 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6169
No description provided.