{"record":{"id":"e930778df57cf8a5","repo":"MHSanaei/3x-ui","slug":"outbound-subscription-response-body-exceeds-size-l-e93077","errorCode":null,"errorMessage":"outbound subscription response body exceeds size limit (limit: %d bytes)","messagePattern":"outbound subscription response body exceeds size limit \\(limit: (.+?) bytes\\)","errorType":"exception","errorClass":"errOutboundSubscriptionBodyTooLarge","httpStatus":null,"severity":"warning","filePath":"internal/web/service/outbound_subscription.go","lineNumber":69,"sourceCode":"\t\tkept = append(kept, ob)\n\t}\n\treturn kept, dropped\n}\n\n// maxOutboundSubscriptionBytes caps a single outbound subscription response.\n// It is larger than the 2 MiB user-facing subscription cap because an outbound\n// subscription may aggregate many upstream outbounds into one document.\nconst maxOutboundSubscriptionBytes int64 = 8 << 20\n\nvar errOutboundSubscriptionBodyTooLarge = errors.New(\"outbound subscription response body exceeds size limit\")\n\nfunc readBoundedOutboundSubscriptionBody(r io.Reader) ([]byte, error) {\n\tbody, err := io.ReadAll(io.LimitReader(r, maxOutboundSubscriptionBytes+1))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif int64(len(body)) > maxOutboundSubscriptionBytes {\n\t\treturn nil, fmt.Errorf(\"%w (limit: %d bytes)\", errOutboundSubscriptionBodyTooLarge, maxOutboundSubscriptionBytes)\n\t}\n\treturn body, nil\n}\n\n// OutboundSubscriptionService manages remote outbound subscriptions.\ntype OutboundSubscriptionService struct {\n\tsettingService SettingService\n}\n\n// NewOutboundSubscriptionService returns a service for managing outbound subscriptions.\nfunc NewOutboundSubscriptionService() *OutboundSubscriptionService {\n\treturn &OutboundSubscriptionService{}\n}\n\n// List returns all subscriptions (newest first).\nfunc (s *OutboundSubscriptionService) List() ([]*model.OutboundSubscription, error) {\n\tdb := database.GetDB()\n\tvar subs []*model.OutboundSubscription","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/MHSanaei/3x-ui/blob/ad32144c42455696ea9f14e12168beac3e25f5d2/internal/web/service/outbound_subscription.go#L51-L87","documentation":"readBoundedOutboundSubscriptionBody reads the subscription response through io.LimitReader(body, 8 MiB + 1) and rejects anything longer. The 8 MiB cap (4x the user-facing 2 MiB subscription cap) exists because outbound subscriptions aggregate many upstream outbounds; the +1 trick lets it distinguish 'at limit' from 'over limit' without buffering unbounded data. errOutboundSubscriptionBodyTooLarge is a sentinel, so errors.Is works on the wrapped error.","triggerScenarios":"Refreshing an outbound subscription whose server returns a document larger than 8,388,608 bytes.","commonSituations":"A provider URL that is actually an HTML error page or a listing of thousands of nodes; a copy-pasted wrong URL returning a huge file; an upstream that inflated its node list.","solutions":["Fetch the URL with curl and check the actual size: curl -sL <url> | wc -c","If legitimate, ask the provider for a filtered/smaller subscription or trim it upstream (the panel cap is a constant, not configurable)","If it is an HTML page, the URL is wrong — fix the subscription URL"],"exampleFix":"curl -sL https://provider.example/sub | wc -c   # > 8388608 means rejection is expected\n# use a filtered link, e.g. provider dashboards usually offer ?limit= or per-group URLs","handlingStrategy":"validation","validationCode":"resp, err := client.Get(sub.Url)\n...\nif resp.ContentLength > 8<<20 {\n    return errors.New(\"subscription document exceeds 8 MiB before download\")\n}","typeGuard":null,"tryCatchPattern":"body, err := readBoundedOutboundSubscriptionBody(resp.Body)\nif err != nil && errors.Is(err, errOutboundSubscriptionBodyTooLarge) {\n    // sentinel is wrapped: report 'document too large', suggest a filtered URL; do not retry blindly\n}","preventionTips":["Use provider-side filtered subscription links for large node lists","Treat a suddenly huge body as a wrong-URL smell (HTML page) and inspect it"],"tags":["limits","subscriptions","outbounds","network"],"backgroundTag":null,"analyzedSha":"ad32144c42455696ea9f14e12168beac3e25f5d2","analyzedAt":"2026-08-15T11:13:23.905Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}