{"record":{"id":"138d94d54fd35e0f","repo":"benbjohnson/litestream","slug":"failed-to-format-response-w-138d94","errorCode":null,"errorMessage":"failed to format response: %w","messagePattern":"failed to format response: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cmd/litestream/status.go","lineNumber":63,"sourceCode":"\n\tfor _, dbConfig := range config.DBs {\n\t\tdb, err := NewDBFromConfig(dbConfig)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Filter if path specified.\n\t\tif filterPath != \"\" && db.Path() != filterPath {\n\t\t\tcontinue\n\t\t}\n\n\t\tstatuses = append(statuses, c.getDBStatus(db))\n\t}\n\n\tif *jsonOutput {\n\t\toutput, err := json.MarshalIndent(statuses, \"\", \"  \")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to format response: %w\", err)\n\t\t}\n\t\tfmt.Println(string(output))\n\t\treturn nil\n\t}\n\n\tw := tabwriter.NewWriter(os.Stdout, 0, 8, 2, ' ', 0)\n\tdefer w.Flush()\n\n\tfmt.Fprintln(w, \"database\\tstatus\\tlocal txid\\twal size\")\n\tfor _, status := range statuses {\n\t\tfmt.Fprintf(w, \"%s\\t%s\\t%s\\t%s\\n\",\n\t\t\tstatus.Database,\n\t\t\tstatus.Status,\n\t\t\tstatus.LocalTXID,\n\t\t\tstatus.WALSize,\n\t\t)\n\t}\n","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/status.go#L45-L81","documentation":"`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.","triggerScenarios":"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.","commonSituations":"Only during development after adding a chan/func/cyclic field to a status struct.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["json","cli","output"],"backgroundTag":"json-marshal-failed","analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}