{"record":{"id":"de6e684f12c2ce81","repo":"MHSanaei/3x-ui","slug":"not-wireguard","errorCode":null,"errorMessage":"not wireguard","messagePattern":"not wireguard","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/util/link/outbound.go","lineNumber":482,"sourceCode":"\n\tob := Outbound{\n\t\t\"protocol\":       \"hysteria\",\n\t\t\"tag\":            decodeHash(u.Fragment),\n\t\t\"settings\":       map[string]any{\"address\": host, \"port\": port, \"version\": 2},\n\t\t\"streamSettings\": stream,\n\t}\n\treturn &ParseResult{Outbound: ob, Identity: identity}, nil\n}\n\n// --- wireguard ---\n\nfunc parseWireguard(link string) (*ParseResult, error) {\n\tu, err := url.Parse(link)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif u.Scheme != \"wireguard\" && u.Scheme != \"wg\" {\n\t\treturn nil, fmt.Errorf(\"not wireguard\")\n\t}\n\tsecret, _ := url.QueryUnescape(u.User.Username())\n\tparams := u.Query()\n\thost := u.Hostname()\n\tportStr := u.Port()\n\tendpoint := host\n\tif portStr != \"\" {\n\t\tendpoint = host + \":\" + portStr\n\t}\n\n\taddrRaw := firstParam(params, \"address\", \"ip\")\n\tallowedRaw := firstParam(params, \"allowedips\", \"allowed_ips\")\n\taddrs := splitComma(addrRaw)\n\tif len(addrs) == 0 {\n\t\taddrs = []string{\"0.0.0.0/0\", \"::/0\"}\n\t}\n\tallowed := splitComma(allowedRaw)\n\tif len(allowed) == 0 {","sourceCodeStart":464,"sourceCodeEnd":500,"githubUrl":"https://github.com/MHSanaei/3x-ui/blob/ad32144c42455696ea9f14e12168beac3e25f5d2/internal/util/link/outbound.go#L464-L500","documentation":"Thrown by parseWireguard in internal/util/link/outbound.go when a link string is routed to the WireGuard parser but its URL scheme is neither 'wireguard' nor 'wg'. The parser dispatcher selects a parser by scheme (or by heuristics for scheme-less links), so this error means the dispatcher guessed WireGuard for a link that is not one. It is a pure input-classification error, not a malformed-WireGuard error.","triggerScenarios":"Calling the outbound link parser (e.g. ParseOutboundLink / the generic dispatch entry point that includes parseWireguard) with a string whose scheme is something else entirely (ss://, vless://, an arbitrary URI, or bare base64) after the dispatcher selected the wireguard branch — typically because the link lacks a recognizable scheme and 'wg'-like content heuristics matched.","commonSituations":"Pasting a wrong subscription link type into a field that expects wireguard:// links; subscription feeds mixing protocols where one entry is truncated or corrupted; a hand-built URL like wg:// with uppercase scheme 'WG://' (url.Parse lowercases scheme, so usually fine) or a typo like 'wirguard://'.","solutions":["Check the link scheme before calling: only pass links starting with wireguard:// or wg:// to parseWireguard.","If parsing arbitrary subscription content, dispatch on the substring before '://' yourself and send non-wg links to the right parser instead of relying on heuristics.","If the link came from a subscription, fetch it again and inspect the raw entries for truncation or HTML error pages.","If you intended a real WireGuard link, fix the scheme prefix to wireguard:// (secret as userinfo, endpoint as host)."],"exampleFix":"// before\nres, err := parseWireguard(link) // link = \"ss://...\" -> \"not wireguard\"\n\n// after\nif scheme := strings.SplitN(link, \"://\", 2)[0]; scheme != \"wireguard\" && scheme != \"wg\" {\n    return nil, fmt.Errorf(\"link is %s, not wireguard\", scheme)\n}\nres, err := parseWireguard(link)","handlingStrategy":"type-guard","validationCode":"func isWireguardLink(link string) bool {\n\ts := strings.ToLower(strings.TrimSpace(link))\n\treturn strings.HasPrefix(s, \"wireguard://\") || strings.HasPrefix(s, \"wg://\")\n}","typeGuard":"func isWireguardLink(link string) bool {\n\ts := strings.ToLower(strings.TrimSpace(link))\n\treturn strings.HasPrefix(s, \"wireguard://\") || strings.HasPrefix(s, \"wg://\")\n}","tryCatchPattern":"if res, err := parseWireguard(link); err != nil {\n    if strings.Contains(err.Error(), \"not wireguard\") {\n        // route link to the correct protocol parser instead\n    }\n    return err\n}","preventionTips":["Dispatch on the substring before '://' before choosing a parser.","Keep one scheme-parsing helper shared by all protocol parsers so classification is centralized.","Reject empty-scheme links early in subscription import."],"tags":["config-parsing","wireguard","url","outbound"],"backgroundTag":null,"analyzedSha":"ad32144c42455696ea9f14e12168beac3e25f5d2","analyzedAt":"2026-08-15T11:13:23.905Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}