[PR #370] [MERGED] fix: remove duplicate wrong error log in socket/fetch and dead code in reliablePing #6513

Closed
opened 2026-06-15 07:35:21 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/fosrl/newt/pull/370
Author: @immanuwell
Created: 5/30/2026
Status: Merged
Merged: 6/4/2026
Merged by: @oschwartz10612

Base: mainHead: fix/docker-fetch-duplicate-log-and-reliable-ping-dead-code


📝 Commits (1)

  • d57b7cc fix: remove duplicate wrong error log in socket/fetch handler and dead code in reliablePing

📊 Changes

2 files changed (+3 additions, -15 deletions)

View changed files

📝 common.go (+3 -11)
📝 main.go (+0 -4)

📄 Description

Community Contribution License Agreement

By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.

Description

Two small bugs fixed:

1. Wrong log message in newt/socket/fetch handler (main.go)

After client.SendMessage("newt/socket/containers", ...) there were two back-to-back if err != nil checks on the same var. The first one had a copy-pasted message from a different handler: "Failed to send registration message" -- totally wrong context. On any send error you'd see that bogus line logged first, then the correct one right after. Dropped the duplicate stale block, kept the one with the right message.

2. Dead code in reliablePing (common.go)

successCount starts at 0 and is only incremented once before the if successCount > 0 guard -- so that condition is always true when reached. The function always returned there, making everything after the loop unreachable. Removed the always-true guard and the dead post-loop code, left the behavior identical.

How to test?

Bug 1 -- check the newt/socket/fetch handler in main.go. With the old code, any error from client.SendMessage would log "Failed to send registration message" (wrong) followed by "Failed to send Docker container list" (right). Now only the correct line fires.

Bug 2 -- static analysis or a quick read: successCount++ immediately before if successCount > 0 guarantees the condition, making the post-loop if successCount == 0 branch and final return unreachable. Behavior is unchanged, code is just honest now.


🔄 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/fosrl/newt/pull/370 **Author:** [@immanuwell](https://github.com/immanuwell) **Created:** 5/30/2026 **Status:** ✅ Merged **Merged:** 6/4/2026 **Merged by:** [@oschwartz10612](https://github.com/oschwartz10612) **Base:** `main` ← **Head:** `fix/docker-fetch-duplicate-log-and-reliable-ping-dead-code` --- ### 📝 Commits (1) - [`d57b7cc`](https://github.com/fosrl/newt/commit/d57b7ccb53e917e37d11a03796251c6de4a3956f) fix: remove duplicate wrong error log in socket/fetch handler and dead code in reliablePing ### 📊 Changes **2 files changed** (+3 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `common.go` (+3 -11) 📝 `main.go` (+0 -4) </details> ### 📄 Description ## Community Contribution License Agreement By creating this pull request, I grant the project maintainers an unlimited, perpetual license to use, modify, and redistribute these contributions under any terms they choose, including both the AGPLv3 and the Fossorial Commercial license terms. I represent that I have the right to grant this license for all contributed content. ## Description Two small bugs fixed: **1. Wrong log message in `newt/socket/fetch` handler (`main.go`)** After `client.SendMessage("newt/socket/containers", ...)` there were two back-to-back `if err != nil` checks on the same var. The first one had a copy-pasted message from a different handler: `"Failed to send registration message"` -- totally wrong context. On any send error you'd see that bogus line logged first, then the correct one right after. Dropped the duplicate stale block, kept the one with the right message. **2. Dead code in `reliablePing` (`common.go`)** `successCount` starts at 0 and is only incremented once before the `if successCount > 0` guard -- so that condition is always true when reached. The function always returned there, making everything after the loop unreachable. Removed the always-true guard and the dead post-loop code, left the behavior identical. ## How to test? Bug 1 -- check the `newt/socket/fetch` handler in `main.go`. With the old code, any error from `client.SendMessage` would log `"Failed to send registration message"` (wrong) followed by `"Failed to send Docker container list"` (right). Now only the correct line fires. Bug 2 -- static analysis or a quick read: `successCount++` immediately before `if successCount > 0` guarantees the condition, making the post-loop `if successCount == 0` branch and final `return` unreachable. Behavior is unchanged, code is just honest now. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-06-15 07:35:21 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/newt#6513