anomalyco/sst · critical

something has corrupted the state file - refusing to upload:

Error message

something has corrupted the state file - refusing to upload: %w

What it means

`PushPartialState` validates the state payload is non-empty, valid JSON before uploading it to the backend. If `json.Unmarshal` fails or the payload is empty, it refuses the upload because a corrupt/empty state file would destroy the stage's state. Note `err` may be nil when only the empty-length check triggers, producing a `%!w(<nil>)` message.

Source

Thrown at pkg/project/provider/provider.go:233

	return data, err
}

func PutSecrets(backend Home, app, stage string, data map[string]string) error {
	if stage == "" {
		stage = "_fallback"
	}
	slog.Info("putting secrets", "app", app, "stage", stage)
	if data == nil {
		return nil
	}
	return putData(backend, "secret", app, stage, true, data)
}

func PushPartialState(backend Home, updateID, app, stage string, data []byte) error {
	slog.Info("pushing partial state", "updateID", updateID)
	err := json.Unmarshal(data, &map[string]interface{}{})
	if err != nil || len(data) == 0 {
		return fmt.Errorf("something has corrupted the state file - refusing to upload: %w", err)
	}
	return backend.putData("app", app, stage, bytes.NewReader(data))
}

func PushSnapshot(backend Home, updateID, app, stage string, data []byte) error {
	slog.Info("pushing snapshot", "updateID", updateID)
	err := json.Unmarshal(data, &map[string]interface{}{})
	if err != nil {
		return fmt.Errorf("something has corrupted the state file - refusing to upload: %w", err)
	}
	return backend.putData("snapshot", app, stage+"/"+updateID, bytes.NewReader(data))
}

func PushEventLog(backend Home, updateID, app, stage string, reader io.Reader) error {
	slog.Info("pushing eventlog", "updateID", updateID)
	return backend.putData("eventlog", app, stage+"/"+updateID, reader)
}

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Inspect the local state for corruption and restore from a snapshot (`sst state` tooling or Pulumi export/import depending on flow)
  2. Re-run the deployment from a clean state; if the stage state is unrecoverable, restore from the backend's last good state or snapshot
  3. Free disk space / fix environment issues that truncated the file, then retry
Defensive patterns

Strategy: validation

Validate before calling

const data = readStateFile();
if (!data || !data.length) throw new Error("empty state, refusing to push");
JSON.parse(data.toString("utf8")); // throws before upload if corrupt

Type guard

function isValidStatePayload(data: Buffer): boolean {
  if (!data || data.length === 0) return false;
  try { JSON.parse(data.toString("utf8")); return true; } catch { return false; }
}

Prevention

When it happens

Trigger: The Pulumi automation engine hands SST an empty or non-JSON partial state blob — typically after a crashed deployment, corrupted local state, or a disk/full-write issue mid-update.

Common situations: Deploy interrupted by OOM or power loss; local `.pulumi/state` corruption; running SST on a filesystem that truncated the temp state file.

Related errors


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/f6a5472059e6ff00. Report an issue: GitHub.