{"record":{"id":"4013736ac49f4ea2","repo":"ory/hydra","slug":"err-error-401373","errorCode":null,"errorMessage":"err.Error()","messagePattern":"err\\.Error\\(\\)","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"oryx/httpx/gzip_server.go","lineNumber":19,"sourceCode":"// Copyright © 2023 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\npackage httpx\n\nimport (\n\t\"compress/gzip\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"strings\"\n)\n\ntype CompressionRequestReader struct {\n\tErrHandler func(w http.ResponseWriter, r *http.Request, err error)\n}\n\nfunc defaultCompressionErrorHandler(w http.ResponseWriter, r *http.Request, err error) {\n\thttp.Error(w, err.Error(), http.StatusBadRequest)\n}\n\nfunc NewCompressionRequestReader(eh func(w http.ResponseWriter, r *http.Request, err error)) *CompressionRequestReader {\n\tif eh == nil {\n\t\teh = defaultCompressionErrorHandler\n\t}\n\n\treturn &CompressionRequestReader{\n\t\tErrHandler: eh,\n\t}\n}\n\nfunc (c *CompressionRequestReader) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {\n\tfor _, enc := range strings.Split(r.Header.Get(\"Content-Encoding\"), \",\") {\n\t\tswitch enc = strings.TrimSpace(enc); enc {\n\t\tcase \"gzip\":\n\t\t\treader, err := gzip.NewReader(r.Body)\n\t\t\tif err != nil {","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/ory/hydra/blob/4174065ffb052799890f7480f5360a877a67ffc1/oryx/httpx/gzip_server.go#L1-L37","documentation":"In defaultCompressionErrorHandler, the raw error text is written as a 400 Bad Request when a request claiming gzip Content-Encoding fails to decompress while being wrapped by the CompressionRequestReader. The client sent a malformed or corrupt gzip body; the error string (from compress/gzip or the reader) names the concrete decoding failure.","triggerScenarios":"Thrown at oryx/httpx/gzip_server.go:19 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Send the body uncompressed or with correctly encoded gzip Content-Encoding","Provide a custom error handler via NewCompressionRequestReader to control the response format","Log decode failures to detect broken clients or malicious payload probing"],"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"}