published fresh until

Terraform “Unsupported state file format”: S3 race?

Summary As of November 2026, the cited report reproduces trailing NUL padding when an S3 state object shrinks during download; a buffer-trimming repair was proposed in [PR #39444](https://github.com/hashicorp/terraform/pull/39444), closed without merging on 2026-10-26, with no verified operational workaround or released fix here.

Not for Terraform 1.17 plan-JSON and provider upgrade breakages, see pnpm-12-terraform-1-17-kubernetes-1-37-tool-upgrade-breakages

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Error: Unsupported state file format — check whether a terraform_remote_state consumer overlaps a writer of the exact same S3 key, comparing timing and object lengths.

The reported shrinking-object race produces a JSON syntax error and missing-version complaint even though stored object versions are valid JSON; a HEAD-sized buffer retains trailing NUL bytes.

First action — Untested experiment: sequence the producer before the consumer, then run terraform plan -input=false in the already initialized consumer directory only after writes stop. Review the plan; do not automatically apply it. The command can contact configured providers and backends. Preserve diagnostics and do not edit stored state.

Evidence: issue #39440 provides a deterministic fake-S3 reproduction, acknowledged and routed by a HashiCorp contributor. PR #39444 proposed buffer trimming and a regression test; it was closed without merging on 2026-10-26 after contribution-process objections (checked 2026-11-14), so release integration remains unestablished. Sequencing remains an untested experiment, not a verified operational workaround or released fix.

Not for: choosing Terraform, OpenTofu or Pulumi for a small team or solo IaC work.

What changed

  • Terraform 1.17.0 release notes, dated 2026-10-21 (version and date checked 2026-10-28), identify the release used in the report; they do not claim this race is fixed.
  • Issue #39440, opened 2026-10-23 (checked 2026-10-28), includes a shrinking-object reproduction. chiliec's proposed buffer-length fix, dated 2026-10-23, was closed without merging on 2026-10-26 after contribution-process objections (checked 2026-11-14).

How to migrate / mitigate

1. Check whether a terraform_remote_state consumer overlaps a writer of that exact S3 key. Preserve the diagnostics and compare timing and object lengths. Handle state copies as sensitive data. 2. Untested experiment: sequence the producer before the consumer, then retry only after writes stop. Run a plan in the already initialized consumer directory using the documented plan command (checked 2026-10-28):

terraform plan -input=false

Review the plan; do not automatically apply it. This command can contact configured providers and backends. 3. If it still fails with stable objects, stop assuming a race. Investigate actual truncation, wrong backend/key, genuine format incompatibility and the first JSON diagnostic. No release upgrade is verified as the fix here. 4. For maintainers evaluating the proposed patch in its source checkout, the PR provides this regression command from internal/backend/remote-state/s3:

go test -run TestRemoteClientGet_objectShrinksBetweenHeadAndDownload ./ -count=1

The test is part of that proposed change, not a command available in every Terraform checkout.

What breaks

Diagnostic: Error: Unsupported state file format

JeremieDoctrine's report (checked 2026-10-28) shows a JSON syntax error followed by a complaint about the missing version attribute even though stored object versions are valid JSON. Its diagnosis is a HEAD-sized buffer retaining trailing NUL bytes when the downloaded replacement is shorter. This does not establish the cause of every format error. Do not add a version field or strip bytes from the authoritative S3 object based on the headline alone.

What to test

Compare unchanged-object and shrinking-object cases in an isolated fixture. For the sequencing experiment, wait for producer completion before repeating the consumer plan. Record the executable build, object sizes and first error. Confirm outputs match the intended object version; successful parsing alone is insufficient.

Pitfalls

A closed, unmerged PR is not a shipped repair. PR #39444 (checked 2026-11-14) proposed trimming to the downloader's actual byte count and supplied a regression test. Do not disable state locking or force-unlock a live writer to mask a read failure. Confirm producer completion directly from its run timestamps.

Evidence

The issue includes a deterministic fake-S3 reproduction; HashiCorp contributor crw acknowledged and routed the report. The proposed patch independently exercises the buffer-length diagnosis, but no release integration is established.

Before making changes

Read issue #39440, PR #39444 and the linked official release and plan references. Check whether the exact state key shrinks during a read. Evaluate producer-to-consumer sequencing as an untested experiment with a read/plan comparison. Never mutate state, disable locking or invent a fixed version. Separate evidence from hypotheses.

Limits

Evidence comes from the report and proposed patch, not broad field confirmation. Sequencing remains an untested experiment; it does not repair genuinely invalid state or guarantee a consistent snapshot against uncontrolled writers.

Started from a post by @JeremieDoctrine, packaged by the editor. Original post

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Terraform “Unsupported state file format”: S3 race?
Summary: As of November 2026, the cited report reproduces trailing NUL padding when an S3 state object shrinks during download; a buffer-trimming repair was proposed in [PR #39444](https://github.com/hashicorp/terraform/pull/39444), closed without merging on 2026-10-26, with no verified operational workaround or released fix here.
Copy for agent
get the whatworks thread terraform-unsupported-state-file-format-s3-shrink-race and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread terraform-unsupported-state-file-format-s3-shrink-race
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp