{"record":{"id":"431e09e705198170","repo":"XTLS/Xray-core","slug":"empty-code","errorCode":null,"errorMessage":"empty code","messagePattern":"empty code","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/geodata/rule_parser.go","lineNumber":72,"sourceCode":"\t\treverse = !reverse\n\t}\n\treturn s, reverse\n}\n\nfunc parseGeoIPRule(rule string, reverse bool) (*IPRule_Geoip, error) {\n\tfile, code, ok := strings.Cut(rule, \":\")\n\tif !ok {\n\t\treturn nil, errors.New(\"syntax error\")\n\t}\n\n\tif file == \"\" {\n\t\treturn nil, errors.New(\"empty file\")\n\t}\n\n\tcode, codeReverse := cutReversePrefix(code)\n\treverse = reverse != codeReverse\n\tif code == \"\" {\n\t\treturn nil, errors.New(\"empty code\")\n\t}\n\tcode = strings.ToUpper(code)\n\n\tif err := checkFile(file, code); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &IPRule_Geoip{\n\t\tGeoip: &GeoIPRule{\n\t\t\tFile:         file,\n\t\t\tCode:         code,\n\t\t\tReverseMatch: reverse,\n\t\t},\n\t}, nil\n}\n\nfunc parseCustomIPRule(rule string, reverse bool) (*IPRule_Custom, error) {\n\tcidr, err := parseCIDR(rule)","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/common/geodata/rule_parser.go#L54-L90","documentation":"After splitting on ':' and stripping '!' reverse prefixes from the code segment, the code is empty. The rule names a file but no country code, e.g. \"ext:geoip.dat:\" or \"geoip:!\".","triggerScenarios":"Rule strings \"geoip:\", \"ext:custom.dat:\", \"geoip:!\"; also \"geoip:!:cn\" is fine but \"geoip:!\" alone is not.","commonSituations":"Config typos where the country code was omitted or deleted after the last colon.","solutions":["Append a valid country code: \"geoip:cn\", \"ext:geoip.dat:us\".","For reverse matching keep the code: \"geoip:!cn\" (the '!' goes before the code, not instead of it)."],"exampleFix":"// before\n\"ip\": [\"ext:geoip.dat:\"]\n\n// after\n\"ip\": [\"ext:geoip.dat:cn\"]","handlingStrategy":"validation","validationCode":"func validGeoIP(r string) bool {\n    parts := strings.Split(strings.Trim(r, \"!\"), \":\")\n    return len(parts) == 2 && parts[0] != \"\" && strings.Trim(parts[1], \"!\") != \"\"\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat '!' as a modifier of a non-empty code, never a replacement for it."],"tags":["geodata","ip-rule","syntax","xray"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}