hashicorp/nomad · error · errInvalidReconcile

%w: %s

Error message

%w: %s

What it means

The task group's disconnect strategy accepts only the enumerated reconcile values ("", best_score, longest_running, keep_original, keep_replacement). Any other string fails Validate and is wrapped with errInvalidReconcile.

Source

Thrown at nomad/structs/group.go:95

		if job.Type != JobTypeService && job.Type != JobTypeBatch {
			mErr = multierror.Append(mErr, errStopAfterNonService)
		}
	}

	if ds.LostAfter < 0 {
		mErr = multierror.Append(mErr, errNegativeLostAfter)
	}

	if ds.StopOnClientAfter != nil && ds.LostAfter != 0 {
		mErr = multierror.Append(mErr, errStopAndLost)
	}

	switch ds.Reconcile {
	case "", ReconcileOptionBestScore, ReconcileOptionLongestRunning,
		ReconcileOptionKeepOriginal, ReconcileOptionKeepReplacement:
	default:
		mErr = multierror.Append(mErr, fmt.Errorf("%w: %s", errInvalidReconcile, ds.Reconcile))
	}

	return mErr.ErrorOrNil()
}

func (ds *DisconnectStrategy) Copy() *DisconnectStrategy {
	if ds == nil {
		return nil
	}

	nds := new(DisconnectStrategy)
	*nds = *ds

	if ds.StopOnClientAfter != nil {
		nds.StopOnClientAfter = new(*ds.StopOnClientAfter)
	}

	if ds.Replace != nil {

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Use one of: best_score, longest_running, keep_original, keep_replacement
  2. Remove the reconcile field to accept the default
  3. Check nomad version docs for the supported reconcile options

Example fix

// before
disconnect { reconcile = "best-effort" }
// after
disconnect { reconcile = "best_score" }
Defensive patterns

Strategy: validation

Validate before calling

var validReconcile = map[string]bool{"": true, "best_score": true, "longest_running": true, "keep_original": true, "keep_replacement": true}
if !validReconcile[ds.Reconcile] {
  return fmt.Errorf("invalid reconcile %q", ds.Reconcile)
}

Try / catch

if err := tg.Disconnect.Validate(); err != nil {
  return fmt.Errorf("fix disconnect.reconcile in job spec: %w", err)
}

Prevention

When it happens

Trigger: Setting group.disconnect.reconcile in a Nomad job spec to an unrecognized value, e.g. reconcile = "best-effort", then running nomad job validate/plan/run.

Common situations: Typo or misspelling of a reconcile option, copying config from an older/newer Nomad version where the option set differs, or case mismatches.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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