{"record":{"id":"a50fca9e09424911","repo":"XTLS/Xray-core","slug":"invalid-scheme-s","errorCode":null,"errorMessage":"invalid scheme: %s","messagePattern":"invalid scheme: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"main/commands/all/api/shared.go","lineNumber":83,"sourceCode":"\t\tdata, err = os.ReadFile(arg)\n\t}\n\n\tif err != nil {\n\t\treturn\n\t}\n\tout = bytes.NewBuffer(data)\n\treturn\n}\n\n// fetchHTTPContent dials https for remote content\nfunc fetchHTTPContent(target string) ([]byte, error) {\n\tparsedTarget, err := url.Parse(target)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif s := strings.ToLower(parsedTarget.Scheme); s != \"http\" && s != \"https\" {\n\t\treturn nil, fmt.Errorf(\"invalid scheme: %s\", parsedTarget.Scheme)\n\t}\n\n\tclient := &http.Client{\n\t\tTimeout: 30 * time.Second,\n\t}\n\tresp, err := client.Do(&http.Request{\n\t\tMethod: \"GET\",\n\t\tURL:    parsedTarget,\n\t\tClose:  true,\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to dial to %s\", target)\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != 200 {\n\t\treturn nil, fmt.Errorf(\"unexpected HTTP status code: %d\", resp.StatusCode)\n\t}","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/main/commands/all/api/shared.go#L65-L101","documentation":"fetchHTTPContent (used by xray CLI api/geo resource fetching) parses the target URL and requires the scheme, lowercased, to be exactly http or https. Any other scheme — or a relative URL whose parsed Scheme is empty — is rejected before any request is made.","triggerScenarios":"Passing a target like \"example.com/geoip.dat\" (no scheme → empty), \"file:///path\", \"data:...\", or \"tls://...\" to a command that fetches remote content (e.g. geodata download paths in config or CLI flags).","commonSituations":"Omitting https:// when setting geoip/geosite download URLs; using a local file path where a URL is expected; scheme typos like \"htps://\".","solutions":["Prefix the URL with https:// (preferred) or http://","For local files, use the local file mechanisms instead of the HTTP fetcher","Double-check scheme spelling"],"exampleFix":"// before\n\"downloadUrl\": \"github.com/v2fly/geoip/releases/latest\" \n\n// after\n\"downloadUrl\": \"https://github.com/v2fly/geoip/releases/latest\"","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function isHTTPURL(s) {\n  try {\n    const u = new URL(s);\n    return u.protocol === \"http:\" || u.protocol === \"https:\";\n  } catch { return false; }\n}\n// assert isHTTPURL(downloadUrl) before handing it to xray config","tryCatchPattern":null,"preventionTips":["Always write the scheme explicitly (https:// preferred)","Use file-based loading for local resources instead of URL fetch"],"tags":["http","url","config","cli"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}