Fix nil pointer panic in Raft-dependent methods during startup (issue #1702)#1831
Merged
Fix nil pointer panic in Raft-dependent methods during startup (issue #1702)#1831
Conversation
…1702) Co-authored-by: vcastellm <47026+vcastellm@users.noreply.github.com>
Co-authored-by: vcastellm <47026+vcastellm@users.noreply.github.com>
Co-authored-by: vcastellm <47026+vcastellm@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Investigate possible cause of issue 1702
Fix nil pointer panic in Raft-dependent methods during startup (issue #1702)
Oct 27, 2025
vcastellm
approved these changes
Dec 11, 2025
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1831 +/- ##
==========================================
+ Coverage 31.39% 31.62% +0.22%
==========================================
Files 76 76
Lines 6806 6817 +11
==========================================
+ Hits 2137 2156 +19
+ Misses 4375 4364 -11
- Partials 294 297 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After node restart, Dkron panics with "runtime error: invalid memory address or nil pointer dereference" causing 5+ minute connection delays. The HTTP server starts before Raft initialization, creating a race where API requests can trigger nil pointer access.
Changes
Added nil checks to Raft-dependent methods:
IsLeader()- returnsfalseleaderMember()- returnsErrLeaderNotFoundLeader()- returns emptyServerAddressapplySetJob()- returns errorRaftApply()- returnsnilStop()- guardsraft.Shutdown()callAdded tests:
Example
Before:
After:
Fixes #1702
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
127.0.0.10/tmp/go-build1868015620/b001/dkron.test -test.testlogfile=/tmp/go-build1868015620/b001/testlog.txt -test.paniconexit0 -test.v=true -test.run=TestAgent|TestIsLeader -test.timeout=1m0s(packet block)/tmp/go-build3610477801/b001/dkron.test -test.testlogfile=/tmp/go-build3610477801/b001/testlog.txt -test.paniconexit0 -test.v=true -test.run=API -test.timeout=2m0s(packet block)127.0.0.11/tmp/go-build830898429/b001/dkron.test -test.testlogfile=/tmp/go-build830898429/b001/testlog.txt -test.paniconexit0 -test.v=true -test.run=TestAgentCommand_runForElection -test.timeout=1m0s(packet block)/tmp/go-build1868015620/b001/dkron.test -test.testlogfile=/tmp/go-build1868015620/b001/testlog.txt -test.paniconexit0 -test.v=true -test.run=TestAgent|TestIsLeader -test.timeout=1m0s(packet block)127.0.0.12/tmp/go-build3610477801/b001/dkron.test -test.testlogfile=/tmp/go-build3610477801/b001/testlog.txt -test.paniconexit0 -test.v=true -test.run=API -test.timeout=2m0s(packet block)127.0.0.14/tmp/go-build3610477801/b001/dkron.test -test.testlogfile=/tmp/go-build3610477801/b001/testlog.txt -test.paniconexit0 -test.v=true -test.run=API -test.timeout=2m0s(packet block)127.0.0.15/tmp/go-build3610477801/b001/dkron.test -test.testlogfile=/tmp/go-build3610477801/b001/testlog.txt -test.paniconexit0 -test.v=true -test.run=API -test.timeout=2m0s(packet block)127.0.0.21/tmp/go-build3610477801/b001/dkron.test -test.testlogfile=/tmp/go-build3610477801/b001/testlog.txt -test.paniconexit0 -test.v=true -test.run=API -test.timeout=2m0s(packet block)127.0.0.22/tmp/go-build3610477801/b001/dkron.test -test.testlogfile=/tmp/go-build3610477801/b001/testlog.txt -test.paniconexit0 -test.v=true -test.run=API -test.timeout=2m0s(packet block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.