{"record":{"id":"331413bb55471f27","repo":"XTLS/Xray-core","slug":"invalid-scheme-u-scheme","errorCode":null,"errorMessage":"invalid scheme + u.Scheme","messagePattern":"invalid scheme \\+ u\\.Scheme","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"infra/conf/transport_finalmask.go","lineNumber":840,"sourceCode":"}\n\nfunc (c *Realm) Build() (proto.Message, error) {\n\tvar scheme, host, port, token, id string\n\tvar stunServers []string\n\tvar tlsConfig *tls.Config\n\n\tu, err := url.Parse(c.Url)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tswitch u.Scheme {\n\tcase \"realm\":\n\t\tscheme = \"https\"\n\tcase \"realm+http\":\n\t\tscheme = \"http\"\n\tdefault:\n\t\treturn nil, errors.New(\"invalid scheme\", u.Scheme)\n\t}\n\n\thost = u.Hostname()\n\tif host == \"\" {\n\t\treturn nil, errors.New(\"invalid host\", host)\n\t}\n\n\tport = u.Port()\n\tif port == \"\" {\n\t\tport = \"443\"\n\t\tif scheme == \"http\" {\n\t\t\tport = \"80\"\n\t\t}\n\t}\n\n\ttoken, err = url.PathUnescape(u.User.String())\n\tif err != nil {\n\t\treturn nil, err","sourceCodeStart":822,"sourceCodeEnd":858,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/infra/conf/transport_finalmask.go#L822-L858","documentation":"Thrown by Realm.Build() while parsing the Realm transport 'url' field: only two schemes are accepted, 'realm' (mapped to https) and 'realm+http' (mapped to http). Any other URL scheme is rejected before host/port/token/id extraction begins.","triggerScenarios":"Setting url to \"https://token@host:port/id\" or \"realm://...\" variants with a typo like \"realms+http://\" triggers this. The value must literally start with realm: or realm+http:.","commonSituations":"Pasting a conventional https:// URL instead of the realm scheme; typos in the scheme; URLs left empty or malformed after template substitution so url.Parse yields an unexpected scheme.","solutions":["Change the url scheme to 'realm://' for TLS-backed (https) transport.","Use 'realm+http://' for plaintext (http) transport.","Double-check for scheme typos and stray characters before the ':'."],"exampleFix":"// before\n\"url\": \"https://mytoken@signal.example.com:8443/v1\"\n// after\n\"url\": \"realm://mytoken@signal.example.com:8443/v1\"","handlingStrategy":"validation","validationCode":"u, err := url.Parse(raw)\nif err != nil || (u.Scheme != \"realm\" && u.Scheme != \"realm+http\") {\n    return fmt.Errorf(\"url must use realm:// or realm+http:// scheme\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never feed plain https:// URLs to the Realm transport field.","Centralize Realm URL construction in one helper that enforces the scheme.","Pre-flight parse every URL field with net/url before handing config to the core."],"tags":["go","xray","config","validation","url-parsing","transport"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}