{"record":{"id":"aa7efd5b34f39300","repo":"MHSanaei/3x-ui","slug":"download-xray-archive-exceeds-d-bytes","errorCode":null,"errorMessage":"download xray: archive exceeds %d bytes","messagePattern":"download xray: archive exceeds (.+?) bytes","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/web/service/server.go","lineNumber":898,"sourceCode":"\t}\n\n\tfileName := fmt.Sprintf(\"Xray-%s-%s.zip\", osName, arch)\n\turl := fmt.Sprintf(\"https://github.com/XTLS/Xray-core/releases/download/%s/%s\", version, fileName)\n\tclient := s.settingService.NewProxiedHTTPClient(60 * time.Second)\n\treq, reqErr := http.NewRequestWithContext(context.Background(), http.MethodGet, url, nil)\n\tif reqErr != nil {\n\t\treturn \"\", reqErr\n\t}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer resp.Body.Close()\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn \"\", fmt.Errorf(\"download xray: unexpected HTTP %d\", resp.StatusCode)\n\t}\n\tif resp.ContentLength > maxXrayArchiveBytes {\n\t\treturn \"\", fmt.Errorf(\"download xray: archive exceeds %d bytes\", maxXrayArchiveBytes)\n\t}\n\n\tfile, err := os.CreateTemp(\"\", \"xray-*.zip\")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tpath := file.Name()\n\tok := false\n\tdefer func() {\n\t\t_ = file.Close()\n\t\tif !ok {\n\t\t\t_ = os.Remove(path)\n\t\t}\n\t}()\n\n\tn, err := io.Copy(file, io.LimitReader(resp.Body, maxXrayArchiveBytes+1))\n\tif err != nil {\n\t\treturn \"\", err","sourceCodeStart":880,"sourceCodeEnd":916,"githubUrl":"https://github.com/MHSanaei/3x-ui/blob/ad32144c42455696ea9f14e12168beac3e25f5d2/internal/web/service/server.go#L880-L916","documentation":"Returned by downloadXRay when the response's declared Content-Length exceeds maxXrayArchiveBytes (200 MiB), before any body is read. It is a pre-flight guard against absurdly large (or malicious) responses. Xray release zips are ~10-25 MiB, so a declared size over 200 MiB means the URL returned the wrong content — usually a proxy error page with a huge declared length or a redirect glitch.","triggerScenarios":"Server declares Content-Length > 209715200 for the asset URL; GitHub serves an error artifact; a filtering proxy announces a giant body.","commonSituations":"Proxy/CDN interception of the download URL; a corrupted release upstream; extremely rare — only fires on declared length, not actual bytes.","solutions":["curl -sIL the asset URL and inspect Content-Length","Bypass or repair the outbound proxy and retry the update","If Xray archives genuinely exceed 200 MiB someday, raise maxXrayArchiveBytes in internal/web/service/server.go and rebuild"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if resp.ContentLength > 0 && resp.ContentLength > maxXrayArchiveBytes {\n    return fmt.Errorf(\"declared size %d exceeds cap; likely wrong content at URL\", resp.ContentLength)\n}\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check declared Content-Length against a sane cap before reading bodies","Validate that download URLs return the expected binary Content-Type","Keep size caps reviewed when upstream artifact sizes legitimately grow"],"tags":["xray-update","size-limit","download"],"backgroundTag":null,"analyzedSha":"ad32144c42455696ea9f14e12168beac3e25f5d2","analyzedAt":"2026-08-15T11:13:23.905Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}