hashicorp/nomad · error

failed to read task state

Error message

failed to read task state: %v

What it means

Same restore path as LocalState: reading structs.TaskState from taskBkt fails with a non-not-found error, aborting GetTaskRunnerState. Indicates corrupted or unreadable task state in the Bolt state store.

Solutions

  1. Verify the task bucket contents with bolt tooling
  2. Wipe the client data dir for that alloc and re-adopt
  3. Check for version skew between the writer and reader of the state format
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at client/state/db_bolt.go:675 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at client/state/db_bolt.go:675

			return nil
		}

		// Restore Local State if it exists
		ls = &trstate.LocalState{}
		if err := taskBkt.Get(taskLocalStateKey, ls); err != nil {
			if !boltdd.IsErrNotFound(err) {
				return fmt.Errorf("failed to read local task runner state: %v", err)
			}

			// Key not found, reset ls to nil
			ls = nil
		}

		// Restore Task State if it exists
		ts = &structs.TaskState{}
		if err := taskBkt.Get(taskStateKey, ts); err != nil {
			if !boltdd.IsErrNotFound(err) {
				return fmt.Errorf("failed to read task state: %v", err)
			}

			// Key not found, reset ts to nil
			ts = nil
		}

		return nil
	})

	if err != nil {
		return nil, nil, err
	}

	return ls, ts, nil
}

// PutTaskRunnerLocalState stores TaskRunner's LocalState or returns an error.
func (s *BoltStateDB) PutTaskRunnerLocalState(allocID, taskName string, val *trstate.LocalState) error {

View on GitHub (pinned to 482b49bf1a)