{"record":{"id":"414f270de0f19f96","repo":"XTLS/Xray-core","slug":"unknown-domain-type","errorCode":null,"errorMessage":"unknown domain type: ","messagePattern":"unknown domain type: ","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/geodata/domain_matcher.go","lineNumber":227,"sourceCode":"\t}\n\treturn false\n}\n\nfunc parseDomain(d *Domain) (strmatcher.Matcher, error) {\n\tif d == nil {\n\t\treturn nil, errors.New(\"domain must not be nil\")\n\t}\n\tswitch d.Type {\n\tcase Domain_Substr:\n\t\treturn strmatcher.Substr.New(strings.ToLower(d.Value))\n\tcase Domain_Regex:\n\t\treturn strmatcher.Regex.New(d.Value)\n\tcase Domain_Domain:\n\t\treturn strmatcher.Domain.New(strings.ToLower(d.Value))\n\tcase Domain_Full:\n\t\treturn strmatcher.Full.New(strings.ToLower(d.Value))\n\tdefault:\n\t\treturn nil, errors.New(\"unknown domain type: \", d.Type)\n\t}\n}\n\nfunc newDomainMatcherFactory() DomainMatcherFactory {\n\tswitch runtime.GOOS {\n\tcase \"ios\", \"android\":\n\t\treturn &CompactDomainMatcherFactory{shared: utils.NewWeakCacheMap[string, strmatcher.LinearAnyMatcher]()}\n\tdefault:\n\t\treturn &MphDomainMatcherFactory{shared: utils.NewWeakCacheMap[string, strmatcher.MphValueMatcher]()}\n\t}\n}\n","sourceCodeStart":209,"sourceCodeEnd":239,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/common/geodata/domain_matcher.go#L209-L239","documentation":"Returned by parseDomain when a protobuf Domain message has a Type outside the known enum values (Substr, Regex, Domain, Full). Since the switch has no matching case, the integer enum value (printed via the variadic errors.New — hence the empty-looking trailing placeholder in static analysis) is rejected. This indicates data written by a newer/unknown schema or corrupted geodata, not a user typo.","triggerScenarios":"Feeding BuildMatcher/CompactDomainMatcher rules whose DomainRule values carry Domain.Type = 4+ — e.g. a geosite.dat produced by a fork that extended the enum, or a hand-crafted protobuf with an unset/garbage type field (type defaults to 0=Full only when valid).","commonSituations":"Mixing dat files from incompatible Xray forks or newer proto schemas with an older binary; corrupted downloads flipping bytes inside the type field; tooling that constructs Domain messages with raw numeric types.","solutions":["Update xray-core to a version that understands the enum value in the error message (the type integer is appended at runtime).","Re-download/regenerate the geosite.dat from the official source and verify its checksum.","If producing Domain messages programmatically, only use Domain_Full/Domain_Domain/Domain_Substr/Domain_Regex constants."],"exampleFix":"// before\nd := &geodata.Domain{Type: geodata.Domain_Type(7), Value: \"example.com\"}\n\n// after\nd := &geodata.Domain{Type: geodata.Domain_Full, Value: \"example.com\"}","handlingStrategy":"type-guard","validationCode":"switch d.Type {\ncase geodata.Domain_Full, geodata.Domain_Domain, geodata.Domain_Substr, geodata.Domain_Regex:\ndefault:\n    // reject before building matchers\n}","typeGuard":"func isValidDomainType(t geodata.Domain_Type) bool {\n    switch t {\n    case geodata.Domain_Full, geodata.Domain_Domain, geodata.Domain_Substr, geodata.Domain_Regex:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Only use generated enum constants, never raw numeric types","Keep geosite.dat and xray-core versions aligned"],"tags":["geodata","protobuf","routing","enum","xray"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}