hashicorp/nomad · error
error parsing server's last_log_index value: %s
Error message
error parsing server's last_log_index value: %s
What it means
The Status().RaftStats endpoint reads the local Raft stats map and parses stats["last_log_index"] with strconv.ParseUint. This error means the value present in the Raft stats map could not be parsed as an unsigned 64-bit integer — the hashicorp/raft library contract is broken (empty string, or unexpected format from an incompatible raft version).
Source
Thrown at nomad/status_endpoint.go:138
Members: members,
}
return nil
}
// RaftStats is used by Autopilot to query the raft stats of the local server.
func (s *Status) RaftStats(args *structs.GenericRequest, reply *structs.RaftStats) error {
// note: we're intentionally throwing away any auth error here and only
// authenticate so that we can measure rate metrics
s.srv.Authenticate(s.ctx, args)
s.srv.MeasureRPCRate("status", structs.RateMetricRead, args)
stats := s.srv.raft.Stats()
var err error
reply.LastContact = stats["last_contact"]
reply.LastIndex, err = strconv.ParseUint(stats["last_log_index"], 10, 64)
if err != nil {
return fmt.Errorf("error parsing server's last_log_index value: %s", err)
}
reply.LastTerm, err = strconv.ParseUint(stats["last_log_term"], 10, 64)
if err != nil {
return fmt.Errorf("error parsing server's last_log_term value: %s", err)
}
return nil
}
// HasNodeConn returns whether the server has a connection to the requested
// Node.
func (s *Status) HasNodeConn(args *structs.NodeSpecificRequest, reply *structs.NodeConnQueryResponse) error {
// note: we're intentionally throwing away any auth error here and only
// authenticate so that we can measure rate metrics
s.srv.Authenticate(s.ctx, args)
s.srv.MeasureRPCRate("status", structs.RateMetricRead, args)
// Validate the argsView on GitHub (pinned to 482b49bf1a)
Solutions
- Check the wrapped '%s' value — strconv messages reveal whether the string was empty or malformed.
- Ensure client and server Nomad versions are compatible (upgrade clients to match servers).
- Retry after the server finishes startup/election; raft stats may be transiently unpopulated.
- Verify no patched/instrumented raft library is in the server build (go version -m nomad).
Example fix
// before
stats, err := agent.Status().RaftStats()
// after
stats, err := agent.Status().RaftStats()
if err != nil && strings.Contains(err.Error(), "last_log_index") {
logger.Warn("raft stats not parseable yet; server may still be initializing", "err", err)
time.Sleep(2 * time.Second)
stats, err = agent.Status().RaftStats()
} Defensive patterns
Strategy: retry
Type guard
func isRaftStatsParseError(err error) bool { return err != nil && strings.Contains(err.Error(), "last_log_index") } Try / catch
stats, err := srv.Status().RaftStats()
if isRaftStatsParseError(err) {
time.Sleep(retryDelay) // server may still be initializing
stats, err = srv.Status().RaftStats()
if err != nil { return fmt.Errorf("raft stats unavailable: %w", err) }
} Prevention
- Keep Nomad client and server versions aligned.
- Only poll raft stats on servers that have completed startup/leader election.
- Avoid patched/instrumented hashicorp/raft builds that change stats keys.
When it happens
Trigger: Calling nomad operator raft / Status().RaftStats (via client RPC 'Status.RaftStats' from fetch) on a server whose raft.Stats() returns a last_log_index that is empty or non-numeric.
Common situations: Version-skew: a Nomad server binary built against a different hashicorp/raft version whose stats keys differ; raft not fully initialized when stats are polled; instrumentation/patching altering stats output.
Related errors
- error parsing server's last_log_term value: %s
- no servers
- users: unable to parse uid/gid from username
- <combined HCL diagnostics from str.String()>
- missing NodeID
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/ba32f96fe4eb4d4a.
Report an issue: GitHub.