benbjohnson/litestream · warning
failed to format response: %w
Error message
failed to format response: %w
What it means
`litestream status -json` failed to json.MarshalIndent the collected DB status slices. Like the sibling start/stop formatter, the status types are JSON-safe structs, so this is a defensive branch that should be unreachable; it guards against future schema changes introducing unmarshalable values.
Source
Thrown at cmd/litestream/status.go:63
for _, dbConfig := range config.DBs {
db, err := NewDBFromConfig(dbConfig)
if err != nil {
return err
}
// Filter if path specified.
if filterPath != "" && db.Path() != filterPath {
continue
}
statuses = append(statuses, c.getDBStatus(db))
}
if *jsonOutput {
output, err := json.MarshalIndent(statuses, "", " ")
if err != nil {
return fmt.Errorf("failed to format response: %w", err)
}
fmt.Println(string(output))
return nil
}
w := tabwriter.NewWriter(os.Stdout, 0, 8, 2, ' ', 0)
defer w.Flush()
fmt.Fprintln(w, "database\tstatus\tlocal txid\twal size")
for _, status := range statuses {
fmt.Fprintf(w, "%s\t%s\t%s\t%s\n",
status.Database,
status.Status,
status.LocalTXID,
status.WALSize,
)
}
View on GitHub (pinned to 4ed7a308f6)
Solutions
- No user action needed with stock litestream
- If you patched the status structs, make every field JSON-encodable (e.g. convert chan/func to strings or omit them)
- Fall back to the tabular output (omit -json) which doesn't marshal
Defensive patterns
Strategy: validation
Prevention
- Keep status structs JSON-encodable; omit unmarshalable fields with `-`
- Cover the -json branch of status in tests
- Fall back to tabular output when -json marshaling fails
When it happens
Trigger: Running `litestream status -json` when one or more databases are registered and the marshaled value contains an unsupported type — not reachable with current status struct definitions.
Common situations: Only during development after adding a chan/func/cyclic field to a status struct.
Understand the failure class
Background: json.Marshal / "failed to marshal" errors in Go: why "unsupported type" happens and how to fix it — this error's family across 22 libraries.
Related errors
- failed to format response: %w
- failed to format response: %w
- failed to format response: %w
- failed to marshal request: %w
- failed to format response: %w
AI-assisted analysis of benbjohnson/litestream@4ed7a308f6 (2026-09-06).
Data as JSON: /api/errors/138d94d54fd35e0f.
Report an issue: GitHub.