{"record":{"id":"8b6ea7861890f4cb","repo":"XTLS/Xray-core","slug":"invalid-packetsfrom","errorCode":null,"errorMessage":"Invalid PacketsFrom","messagePattern":"Invalid PacketsFrom","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"infra/conf/freedom.go","lineNumber":109,"sourceCode":"\t}\n\n\tif c.Fragment != nil {\n\t\tconfig.Fragment = new(freedom.Fragment)\n\n\t\tswitch strings.ToLower(c.Fragment.Packets) {\n\t\tcase \"tlshello\":\n\t\t\t// TLS Hello Fragmentation (into multiple handshake messages)\n\t\t\tconfig.Fragment.PacketsFrom = 0\n\t\t\tconfig.Fragment.PacketsTo = 1\n\t\tcase \"\":\n\t\t\t// TCP Segmentation (all packets)\n\t\t\tconfig.Fragment.PacketsFrom = 0\n\t\t\tconfig.Fragment.PacketsTo = 0\n\t\tdefault:\n\t\t\t// TCP Segmentation (range)\n\t\t\tfrom, to, err := ParseRangeString(c.Fragment.Packets)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errors.New(\"Invalid PacketsFrom\").Base(err)\n\t\t\t}\n\t\t\tconfig.Fragment.PacketsFrom = uint64(from)\n\t\t\tconfig.Fragment.PacketsTo = uint64(to)\n\t\t\tif config.Fragment.PacketsFrom == 0 {\n\t\t\t\treturn nil, errors.New(\"PacketsFrom can't be 0\")\n\t\t\t}\n\t\t}\n\n\t\t{\n\t\t\tif c.Fragment.Length == nil {\n\t\t\t\treturn nil, errors.New(\"Length can't be empty\")\n\t\t\t}\n\t\t\tconfig.Fragment.LengthMin = uint64(c.Fragment.Length.From)\n\t\t\tconfig.Fragment.LengthMax = uint64(c.Fragment.Length.To)\n\t\t\tif config.Fragment.LengthMin == 0 {\n\t\t\t\treturn nil, errors.New(\"LengthMin can't be 0\")\n\t\t\t}\n\t\t}","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/infra/conf/freedom.go#L91-L127","documentation":"Thrown while parsing the freedom outbound's fragment 'packets' setting when it is neither \"tlshello\" nor empty: the value is treated as a numeric range string (e.g. \"1-3\") and ParseRangeString fails. The underlying parse error is chained via .Base(err), so the full message shows why the range is malformed.","triggerScenarios":"\"fragment\": {\"packets\": \"1:3\"} (colon instead of dash), \"packets\": \"1-\", \"packets\": \"abc\" — any value that ParseRangeString cannot parse as a from-to range. The \"tlshello\" and \"\" special cases bypass this path.","commonSituations":"Using wrong range separators; copying fragment examples from other projects that use 'x:y' notation; stray whitespace or unicode dashes.","solutions":["Write the packets range as \"from-to\", e.g. \"1-3\" for TCP segmentation of packets 1 through 3.","Use \"tlshello\" for TLS-hello fragmentation or omit/empty for all packets.","Read the chained base error to see the exact parse failure reason."],"exampleFix":"// before\n\"packets\": \"1:3\"\n\n// after\n\"packets\": \"1-3\"","handlingStrategy":"validation","validationCode":"if p := fragment.Packets; p != \"\" && p != \"tlshello\" {\n    if _, _, err := ParseRangeString(p); err != nil {\n        return fmt.Errorf(\"fragment.packets %q must be 'tlshello', '', or 'N-M': %w\", p, err)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use dash-separated ranges (\"1-3\"), not colon-separated.","Reserve \"tlshello\" and \"\" for their special meanings.","Lint fragment sub-fields together in one check."],"tags":["go","xray","freedom","fragment","config","validation"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}