{"record":{"id":"30d2e02e82d74405","repo":"benbjohnson/litestream","slug":"failed-to-format-response-w-30d2e0","errorCode":null,"errorMessage":"failed to format response: %w","messagePattern":"failed to format response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/info.go","lineNumber":75,"sourceCode":"\t}\n\n\tif resp.StatusCode != http.StatusOK {\n\t\tvar errResp litestream.ErrorResponse\n\t\tif err := json.Unmarshal(body, &errResp); err == nil && errResp.Error != \"\" {\n\t\t\treturn fmt.Errorf(\"info failed: %s\", errResp.Error)\n\t\t}\n\t\treturn fmt.Errorf(\"info failed: %s\", string(body))\n\t}\n\n\tvar result litestream.InfoResponse\n\tif err := json.Unmarshal(body, &result); err != nil {\n\t\treturn fmt.Errorf(\"failed to parse response: %w\", err)\n\t}\n\n\tif *jsonOutput {\n\t\toutput, err := json.MarshalIndent(result, \"\", \"  \")\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} else {\n\t\tuptime := time.Duration(result.UptimeSeconds) * time.Second\n\t\tfmt.Printf(\"Litestream %s\\n\", result.Version)\n\t\tfmt.Printf(\"  PID:        %d\\n\", result.PID)\n\t\tfmt.Printf(\"  Uptime:     %s\\n\", uptime)\n\t\tfmt.Printf(\"  Started at: %s\\n\", result.StartedAt.Format(time.RFC3339))\n\t\tfmt.Printf(\"  Databases:  %d\\n\", result.DatabaseCount)\n\t}\n\n\treturn nil\n}\n\n// Usage prints the help text for the info command.\nfunc (c *InfoCommand) Usage() {\n\tfmt.Println(`\nusage: litestream info [OPTIONS]","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/info.go#L57-L93","documentation":"When --json output is requested, Run re-marshals the successfully parsed InfoResponse with json.MarshalIndent for pretty printing. Failing here is effectively an internal invariant violation — a struct that json.Unmarshal just produced should serialize — but the error is wrapped and returned rather than ignored.","triggerScenarios":"Theoretically triggered by a field in InfoResponse that cannot be marshaled (e.g. an unsupported value injected during decode such as a channel/func via custom UnmarshalJSON, or NaN-like values in custom types).","commonSituations":"Practically never hit by end users; encountered only with patched/modified builds of litestream where InfoResponse gained a non-JSON-serializable field or a custom marshaler with a bug.","solutions":["Retry the command; if it persists, it indicates a build defect.","Verify you are running an official litestream release binary (rebuild from a clean checkout if custom).","Report the issue with your version string if it reproduces on an official release.","As a workaround use non-JSON output (omit --json) which prints via fmt.Printf and avoids the marshal path."],"exampleFix":"// before\n$ litestream info --json   # custom build with broken marshaler\n// after\n$ go install github.com/benbjohnson/litestream/cmd/litestream@latest\n$ litestream info --json","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := runInfoJSON(ctx); err != nil && strings.Contains(err.Error(), \"failed to format response\") {\n    // marshal of a freshly-decoded struct should never fail; fall back to text output\n    return runInfoText(ctx)\n}","preventionTips":["Run official litestream release binaries; custom patches to InfoResponse are the usual cause.","Use non-JSON output when you do not strictly need machine-readable output.","Report reproducible marshal failures upstream with the version string."],"tags":["json","serialization","cli"],"backgroundTag":"json-serialization-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"}