hashicorp/nomad · error

Reload given a nil config

Error message

Reload given a nil config

What it means

Server.Reload was called with a nil configuration object; the reload path guards against a missing config before applying server-only config changes.

Source

Thrown at nomad/server.go:914

		// to evaluate during the RC period if this interim situation is
		// not too confusing for operators.

		// TODO (alexdadgar) When we take a later new version of the Raft
		// library it won't try to complete replication, so this peer
		// may not realize that it has been removed. Need to revisit this
		// and the warning here.
		if !left {
			s.logger.Warn("failed to leave raft configuration gracefully, timeout")
		}
	}
	return nil
}

// Reload handles a config reload specific to server-only configuration. Not
// all config fields can handle a reload.
func (s *Server) Reload(newConfig *Config) error {
	if newConfig == nil {
		return fmt.Errorf("Reload given a nil config")
	}

	var mErr multierror.Error

	shouldReloadTLS, err := tlsutil.ShouldReloadRPCConnections(s.config.TLSConfig, newConfig.TLSConfig)
	if err != nil {
		s.logger.Error("error checking whether to reload TLS configuration", "error", err)
	}

	if shouldReloadTLS {
		if err := s.reloadTLSConnections(newConfig.TLSConfig); err != nil {
			s.logger.Error("error reloading server TLS configuration", "error", err)
			_ = multierror.Append(&mErr, err)
		}
	}

	if newConfig.LicenseConfig.LicenseEnvBytes != "" || newConfig.LicenseConfig.LicensePath != "" {
		if err = s.EnterpriseState.ReloadLicense(newConfig); err != nil {

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Ensure the caller builds and parses a valid Config before invoking Reload.
  2. Return/handle the config-parse error upstream instead of passing nil through.
  3. If reload is conditional, check for nil newConfig before calling Reload.

Example fix

// before
cfg, err := loadConfig(path)
return srv.Reload(cfg) // cfg is nil when loadConfig failed
// after
cfg, err := loadConfig(path)
if err != nil {
    return err
}
return srv.Reload(cfg)
Defensive patterns

Strategy: type-guard

Validate before calling

func safeReload(srv *nomad.Server, cfg *nomad.Config) error {
    if cfg == nil {
        return errors.New("reload aborted: nil config")
    }
    return srv.Reload(cfg)
}

Type guard

func validReloadConfig(c *nomad.Config) bool { return c != nil }

Try / catch

if err := srv.Reload(cfg); err != nil && strings.Contains(err.Error(), "nil config") {
    return fmt.Errorf("caller bug: reload invoked without parsed config: %w", err)
}

Prevention

When it happens

Trigger: Calling Server.Reload(nil) programmatically — e.g. a test, integration harness, or wrapper that constructs the new config conditionally and passes nil when parsing fails or the config map is empty.

Common situations: Internal callers/tests of the agent package, config reload tooling that skips config parsing on error yet still invokes Reload, or API integrations embedding Nomad server code.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/c34a51bd73426e04. Report an issue: GitHub.