{"record":{"id":"7da31b4bc3536f71","repo":"benbjohnson/litestream","slug":"failed-to-format-response-w-7da31b","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/register.go","lineNumber":105,"sourceCode":"\t\t}\n\t\treturn fmt.Errorf(\"register failed: %s\", string(body))\n\t}\n\n\tvar result litestream.RegisterDatabaseResponse\n\tif err := json.Unmarshal(body, &result); err != nil {\n\t\treturn fmt.Errorf(\"failed to parse response: %w\", err)\n\t}\n\n\tconfirmation := RegisterResult{\n\t\tStatus:  result.Status,\n\t\tDBPath:  result.Path,\n\t\tReplica: replicaURL,\n\t\tSocket:  *socketPath,\n\t}\n\tif *jsonOutput {\n\t\toutput, err := json.MarshalIndent(confirmation, \"\", \"  \")\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\tfmt.Printf(\"status: %s\\n\", registerDisplayStatus(confirmation.Status))\n\tfmt.Printf(\"db_path: %s\\n\", confirmation.DBPath)\n\tfmt.Printf(\"replica: %s\\n\", confirmation.Replica)\n\tfmt.Printf(\"socket: %s\\n\", confirmation.Socket)\n\n\treturn nil\n}\n\ntype RegisterResult struct {\n\tStatus  string `json:\"status\"`\n\tDBPath  string `json:\"db_path\"`\n\tReplica string `json:\"replica\"`\n\tSocket  string `json:\"socket\"`","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/register.go#L87-L123","documentation":"With -json, the command re-serializes the local RegisterResult confirmation struct with json.MarshalIndent for pretty output. If that marshal fails, it returns 'failed to format response'. Like error 151, this is effectively unreachable with the current all-string fields and signals an internal problem rather than user error.","triggerScenarios":"json.MarshalIndent failing on RegisterResult — only possible if fields become non-marshalable types (custom build/fork) or a custom MarshalJSON returns an error.","commonSituations":"Forks or patches adding complex fields to RegisterResult; custom JSON marshalers erroring; essentially never seen in stock litestream.","solutions":["Run a stock litestream build to rule out local modifications","Check the wrapped %w cause and any custom MarshalJSON on RegisterResult","Use non-JSON output (drop -json) as a temporary workaround"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := registerCmd.Run(ctx, args); err != nil {\n    if strings.Contains(err.Error(), \"failed to format response\") {\n        // non-marshalable RegisterResult field — internal bug; fall back to text output\n        runWithoutJSONFlag(args)\n    }\n}","preventionTips":["Keep RegisterResult fields JSON-encodable in forks","Report the bug upstream if hit on a stock build","Drop -json as a fallback"],"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"}