{"record":{"id":"cc1eaf56613dea7e","repo":"XTLS/Xray-core","slug":"failed-to-find-the-default-name-config","errorCode":null,"errorMessage":"failed to find the default \"name\" config","messagePattern":"failed to find the default \"name\" config","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"proxy/trojan/server.go","lineNumber":405,"sourceCode":"\n\tif len(napfb) > 1 || napfb[\"\"] == nil {\n\t\tif name != \"\" && napfb[name] == nil {\n\t\t\tmatch := \"\"\n\t\t\tfor n := range napfb {\n\t\t\t\tif n != \"\" && strings.Contains(name, n) && len(n) > len(match) {\n\t\t\t\t\tmatch = n\n\t\t\t\t}\n\t\t\t}\n\t\t\tname = match\n\t\t}\n\t}\n\n\tif napfb[name] == nil {\n\t\tname = \"\"\n\t}\n\tapfb := napfb[name]\n\tif apfb == nil {\n\t\treturn errors.New(`failed to find the default \"name\" config`).AtWarning()\n\t}\n\n\tif apfb[alpn] == nil {\n\t\talpn = \"\"\n\t}\n\tpfb := apfb[alpn]\n\tif pfb == nil {\n\t\treturn errors.New(`failed to find the default \"alpn\" config`).AtWarning()\n\t}\n\n\tpath := \"\"\n\tif len(pfb) > 1 || pfb[\"\"] == nil {\n\t\tif firstLen >= 18 && first.Byte(4) != '*' { // not h2c\n\t\t\tfirstBytes := first.Bytes()\n\t\t\tfor i := 4; i <= 8; i++ { // 5 -> 9\n\t\t\t\tif firstBytes[i] == '/' && firstBytes[i-1] == ' ' {\n\t\t\t\t\tsearch := len(firstBytes)\n\t\t\t\t\tif search > 64 {","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/proxy/trojan/server.go#L387-L423","documentation":"In the trojan fallback path, after selecting a fallback 'name' from the SNI/header sniffing, napfb[name] is nil and even the unnamed default napfb[\"\"] is nil — so no fallback group exists for this traffic at all. It is a configuration-shape error: fallbacks were configured, but none qualifies as the default.","triggerScenarios":"All configured fallback entries carry a 'name' that does not match the sniffed name, and no entry with an empty name was provided (the required catch-all).","commonSituations":"Admin adds only named fallbacks (e.g. for specific SNI domains) and forgets the default; YAML/JSON indentation puts fallbacks under the wrong key so the map builds empty.","solutions":["Add a fallback entry without 'name' (empty name) to serve as the default catch-all","Verify each fallback object's fields parse as expected (name/alpn/path/dest/type/xver) in the config","Check the sniffed SNI actually matches the names you configured (case sensitivity)"],"exampleFix":"// json: last entry with no name/alpn/path is the required default\n\"fallbacks\": [\n  {\"name\": \"a.example.com\", \"dest\": 8001},\n  {\"name\": \"b.example.com\", \"dest\": 8002},\n  {\"dest\": 8080}\n]","handlingStrategy":"validation","validationCode":"// config validation before starting the trojan inbound\nfunc validateFallbacks(fbs []Fallback) error {\n    hasDefault := false\n    for _, f := range fbs {\n        if f.Name == \"\" { hasDefault = true }\n    }\n    if !hasDefault {\n        return errors.New(\"fallbacks need at least one entry without 'name'\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include one name-less, alpn-less, path-less fallback entry as catch-all","Lint fallback config in CI with a JSON-schema check for the trojan inbound","Keep fallback key discipline: name=SNI, alpn=TLS-ALPN, path=HTTP path"],"tags":["trojan","fallback","config"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}