{"record":{"id":"5de9598792d415ca","repo":"benbjohnson/litestream","slug":"failed-to-parse-response-w-5de959","errorCode":null,"errorMessage":"failed to parse response: %w","messagePattern":"failed to parse response: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/start.go","lineNumber":84,"sourceCode":"\t}\n\tdefer resp.Body.Close()\n\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to read response: %w\", err)\n\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(\"start failed: %s\", errResp.Error)\n\t\t}\n\t\treturn fmt.Errorf(\"start failed: %s\", string(body))\n\t}\n\n\tvar result litestream.StartResponse\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 := StartStopResult{\n\t\tStatus: result.Status,\n\t\tDBPath: result.Path,\n\t\tState:  \"running\",\n\t\tTXID:   result.TXID,\n\t\tSocket: *socketPath,\n\t}\n\tif err := printStartStopResult(confirmation, *jsonOutput); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\ntype StartStopResult struct {\n\tStatus string `json:\"status\"`","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/start.go#L66-L102","documentation":"The daemon returned HTTP 200, but the response body could not be unmarshaled into litestream.StartResponse. The CLI wraps the json.Unmarshal error as 'failed to parse response'. This is a contract mismatch between daemon and CLI: truncated, non-JSON, or schema-drifted JSON.","triggerScenarios":"Successful /start response whose body is truncated (connection cut after headers), is not JSON (proxy injected content), or whose fields don't match StartResponse because CLI and daemon versions differ.","commonSituations":"Upgrading the CLI but not the daemon (or vice versa) so response fields changed; a caching/proxy layer rewriting the body; daemon bug emitting partial JSON on success.","solutions":["Pin CLI and daemon to the same litestream version","Fetch the raw body (curl --unix-socket /var/run/litestream.sock http://localhost/start) to inspect what the daemon actually returned","Retry in case of a truncated response; check daemon logs for panics mid-write","If persistent, file/inspect for a daemon bug writing malformed JSON on success"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// verify compatibility before parsing in wrappers:\n// compare `litestream version` output of daemon and CLI","typeGuard":"func validStartResponse(b []byte) bool {\n    var r litestream.StartResponse\n    return json.Unmarshal(b, &r) == nil && r.Status != \"\"\n}","tryCatchPattern":"var jsonErr *json.UnmarshalTypeError\nif errors.As(err, &jsonErr) {\n    log.Printf(\"daemon/CLI schema mismatch at %s\", jsonErr.Field)\n}","preventionTips":["Upgrade daemon and CLI together","Integration-test start -json output after version bumps","Alert on any non-JSON bytes in IPC responses"],"tags":["json","cli","ipc","version-mismatch"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}