{"record":{"id":"554093d694476eba","repo":"MHSanaei/3x-ui","slug":"vmess-json-w","errorCode":null,"errorMessage":"vmess json: %w","messagePattern":"vmess json: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/util/link/outbound.go","lineNumber":146,"sourceCode":"\t}\n}\n\n// --- vmess ---\n\nfunc parseVmess(link string) (*ParseResult, error) {\n\tb64 := strings.TrimPrefix(link, \"vmess://\")\n\t// vmess:// base64(json)\n\traw, err := base64.StdEncoding.DecodeString(padBase64(b64))\n\tif err != nil {\n\t\t// Some providers use raw URL-safe\n\t\traw, err = base64.RawURLEncoding.DecodeString(b64)\n\t}\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"vmess decode: %w\", err)\n\t}\n\tvar j map[string]any\n\tif err := json.Unmarshal(raw, &j); err != nil {\n\t\treturn nil, fmt.Errorf(\"vmess json: %w\", err)\n\t}\n\n\tidentity := vmessIdentity(j)\n\n\tnetwork := getString(j, \"net\", \"tcp\")\n\tsecurity := \"none\"\n\tif tls, _ := j[\"tls\"].(string); tls == \"tls\" {\n\t\tsecurity = \"tls\"\n\t}\n\tstream := buildStream(network, security)\n\n\t// Map known fields (best effort, matching frontend parser coverage)\n\tswitch network {\n\tcase \"ws\":\n\t\thost, _ := j[\"host\"].(string)\n\t\tsetWS(stream, host, getString(j, \"path\", \"/\"))\n\tcase \"grpc\":\n\t\tsvc := getString(j, \"path\", \"\")","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/MHSanaei/3x-ui/blob/ad32144c42455696ea9f14e12168beac3e25f5d2/internal/util/link/outbound.go#L128-L164","documentation":"Returned by parseVmess when the base64 payload decoded fine but json.Unmarshal into map[string]any fails — the bytes are not valid JSON. VMess links are base64(JSON objects); this error means the decoded content is something else (HTML error page, binary, plain-text host:port, or another layer of encoding). Field extraction cannot proceed.","triggerScenarios":"Payload that was double-base64-encoded; a provider serving an HTML/cloudflare challenge page encoded as the 'link'; JSON with trailing garbage or BOM; a vmess link generated by a client that writes a v2 JSON-N format with comments/trailing commas.","commonSituations":"Subscription URLs fetched without a proper User-Agent returning wrapped error bodies; links forwarded through tools that mangled quotes; hand-built vmess links where someone base64'd the string twice.","solutions":["Decode the payload manually (base64 → string) and LOOK at it — you will immediately see whether it is JSON, HTML, or binary.","If it is double-encoded, base64-decode a second time before re-importing.","If it is an HTML challenge page, re-fetch the subscription with the correct client headers or from a different network.","Rebuild the link in the source client's export function instead of hand-assembling it."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"func hasVmessJSONPayload(link string) bool {\n    s := strings.TrimPrefix(link, \"vmess://\")\n    raw, err := base64.RawURLEncoding.DecodeString(strings.TrimRight(s, \"=\"))\n    if err != nil { raw, _ = base64.StdEncoding.DecodeString(padBase64(s)) }\n    if len(raw) == 0 || raw[0] != '{' { return false }\n    return json.Valid(raw)\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"vmess json\") {\n    // decoded bytes were not JSON: likely an HTML error page or double-encoded payload; drop the entry\n}","preventionTips":["Fetch subscriptions with a realistic User-Agent to avoid challenge pages.","Avoid double base64-encoding when generating vmess links.","Spot-check decoded payloads during development."],"tags":["parsing","proxy-links","vmess","json"],"backgroundTag":null,"analyzedSha":"ad32144c42455696ea9f14e12168beac3e25f5d2","analyzedAt":"2026-08-15T11:13:23.905Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}