{"record":{"id":"e847e53cc6e9f6ef","repo":"ory/hydra","slug":"server-error-e847e5","errorCode":"server_error","errorMessage":"ErrServerError.WithWrap(err).WithDebug(err.Error()).Error()","messagePattern":"ErrServerError\\.WithWrap\\(err\\)\\.WithDebug\\(err\\.Error\\(\\)\\)\\.Error\\(\\)","errorType":"http","errorClass":"ErrServerError","httpStatus":500,"severity":"error","filePath":"fosite/device_write.go","lineNumber":37,"sourceCode":"\t}\n\n\trw.Header().Set(\"Content-Type\", \"application/json;charset=UTF-8\")\n\trw.Header().Set(\"Cache-Control\", \"no-store\")\n\trw.Header().Set(\"Pragma\", \"no-cache\")\n\n\tdeviceResponse := &DeviceResponse{\n\t\tDeviceCode:              responder.GetDeviceCode(),\n\t\tUserCode:                responder.GetUserCode(),\n\t\tVerificationURI:         responder.GetVerificationURI(),\n\t\tVerificationURIComplete: responder.GetVerificationURIComplete(),\n\t\tExpiresIn:               responder.GetExpiresIn(),\n\t\tInterval:                responder.GetInterval(),\n\t}\n\n\tr, err := json.Marshal(deviceResponse)\n\t_, _ = rw.Write(r)\n\tif err != nil {\n\t\thttp.Error(rw, ErrServerError.WithWrap(err).WithDebug(err.Error()).Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n}\n","sourceCodeStart":19,"sourceCodeEnd":41,"githubUrl":"https://github.com/ory/hydra/blob/4174065ffb052799890f7480f5360a877a67ffc1/fosite/device_write.go#L19-L41","documentation":"In WriteDeviceResponse, this expression is the server-error branch used when marshaling the DeviceResponse to JSON fails: the OAuth2 device-flow response cannot be serialized, and a generic RFC6749 server_error (500) is written instead. Marshal of a freshly built struct rarely fails, so reaching it indicates an internal inconsistency.","triggerScenarios":"Thrown at fosite/device_write.go:37 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped marshal error for the offending field in DeviceResponse","Treat as an internal server error; respond 500 with server_error per RFC 6749","Add tests covering the response shape so serialization regressions are caught in CI"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4174065ffb052799890f7480f5360a877a67ffc1","analyzedAt":"2026-09-03T14:52:41.581Z","contentChangedAt":"2026-09-03T14:52:41.581Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}