hashicorp/terraform · error

state data in OSS does not have the expected content. This…

Error message

state data in OSS does not have the expected content.

This may be caused by unusually long delays in OSS processing a previous state
update.  Please wait for a minute or two and try again. If this problem
persists, and neither OSS nor Tablestore are experiencing an outage, you may need
to manually verify the remote state and update the Digest value stored in the
TableStore table to the following value: %x

What it means

Thrown by RemoteClient.Get after retrying: the MD5 digest stored in Tablestore does not match the MD5 of the OSS state object retrieved, and the retry deadline expired. OSS eventual consistency caused a stale object read; the backend refuses to return state whose integrity cannot be verified.

Solutions

  1. Wait 1–2 minutes for OSS consistency to settle, then retry terraform plan/apply.
  2. If persistent, manually compute the current OSS object MD5 and update the Digest value in the Tablestore lock row to match the format shown (%x).
  3. Verify no external process is overwriting the OSS state object outside terraform.
  4. Confirm OSS and Tablestore are not in separate regions/endpoint configurations that increase replication lag.
Defensive patterns

Strategy: retry

Try / catch

// On MD5 mismatch, retry with backoff up to the consistency window; only then surface the digest.
for attempt := 0; attempt < maxAttempts; attempt++ {
    payload, err := get()
    if err == nil || !isBadChecksum(err) { return payload, err }
    time.Sleep(consistencyRetryPollInterval)
}
return nil, fmt.Errorf(errBadChecksumFmt, digest)

Prevention

When it happens

Trigger: A prior Put wrote a new state and its MD5 to Tablestore, but a subsequent Get read a stale OSS object (pre-update) whose MD5 differs from the stored digest. After consistencyRetryPollInterval retries until the deadline, the mismatch persists.

Common situations: OSS eventual-consistency lag, especially cross-region or right after a fast double-apply; a previous write was partial; an out-of-band tool modified the OSS object without updating Tablestore.

Related errors


AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11). Data as JSON: /api/errors/e57086fa2d80bb46. Report an issue: GitHub.

Appendix: source

Thrown at internal/backend/remote-state/oss/client.go:92

		}

		// verify that this state is what we expect
		if expected, err := c.getMD5(); err != nil {
			log.Printf("[WARN] failed to fetch state md5: %s", err)
		} else if len(expected) > 0 && !bytes.Equal(expected, digest) {
			log.Printf("[WARN] state md5 mismatch: expected '%x', got '%x'", expected, digest)

			if testChecksumHook != nil {
				testChecksumHook()
			}

			if time.Now().Before(deadline) {
				time.Sleep(consistencyRetryPollInterval)
				log.Println("[INFO] retrying OSS RemoteClient.Get...")
				continue
			}

			return nil, diags.Append(fmt.Errorf(errBadChecksumFmt, digest))
		}

		break
	}
	return payload, diags
}

func (c *RemoteClient) Put(data []byte) tfdiags.Diagnostics {
	var diags tfdiags.Diagnostics
	bucket, err := c.ossClient.Bucket(c.bucketName)
	if err != nil {
		return diags.Append(fmt.Errorf("error getting bucket: %#v", err))
	}

	body := bytes.NewReader(data)

	var options []oss.Option
	if c.acl != "" {

View on GitHub (pinned to d32a084675)