{"record":{"id":"c92a9771b6974563","repo":"ory/kratos","slug":"webhook-response-body-could-not-be-read","errorCode":null,"errorMessage":"webhook response body could not be read","messagePattern":"webhook response body could not be read","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"selfservice/hook/web_hook.go","lineNumber":468,"sourceCode":"\t\t}\n\t}\n\treturn res\n}\n\nfunc parseWebhookResponse(resp *http.Response, id *identity.Identity) (err error) {\n\tif resp == nil {\n\t\treturn errors.Errorf(\"empty response provided from the webhook\")\n\t}\n\n\tif resp.StatusCode == http.StatusOK {\n\t\ttype localIdentity identity.Identity\n\t\tvar hookResponse struct {\n\t\t\tIdentity *localIdentity `json:\"identity\"`\n\t\t}\n\t\t// io.ReadAll is safe, because resp.Body is already a limited reader.\n\t\tbody, err := io.ReadAll(resp.Body)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"webhook response body could not be read\")\n\t\t}\n\t\tif err = json.Unmarshal(body, &hookResponse); err != nil {\n\t\t\treturn errors.Wrap(err, \"webhook response could not be unmarshalled properly from JSON\")\n\t\t}\n\n\t\tif hookResponse.Identity == nil {\n\t\t\treturn nil\n\t\t}\n\n\t\tif len(hookResponse.Identity.Traits) > 0 {\n\t\t\tid.Traits = hookResponse.Identity.Traits\n\t\t}\n\n\t\tif len(hookResponse.Identity.SchemaID) > 0 {\n\t\t\tid.SchemaID = hookResponse.Identity.SchemaID\n\t\t}\n\n\t\tif len(hookResponse.Identity.State) > 0 {","sourceCodeStart":450,"sourceCodeEnd":486,"githubUrl":"https://github.com/ory/kratos/blob/b86338da04a040247a07f46100a86dcfb3875909/selfservice/hook/web_hook.go#L450-L486","documentation":"The webhook returned HTTP 200 and the courier tried to read its body through the pre-limited reader, but io.ReadAll failed. This is an I/O-level failure while streaming the response (connection reset mid-body, read timeout), not a content problem.","triggerScenarios":"Thrown at selfservice/hook/web_hook.go:468 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the flow - transient network truncation is the most common cause","Check for proxies or load balancers that cut long-lived response bodies","Verify the webhook endpoint closes responses cleanly"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b86338da04a040247a07f46100a86dcfb3875909","analyzedAt":"2026-09-07T15:58:15.934Z","contentChangedAt":"2026-09-07T15:58:15.934Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}