{"record":{"id":"c7148387d603858a","repo":"XTLS/Xray-core","slug":"failed-to-parse-http-account","errorCode":null,"errorMessage":"failed to parse HTTP account","messagePattern":"failed to parse HTTP account","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"infra/conf/http.go","lineNumber":109,"sourceCode":"\t\t\tPort:    uint32(serverConfig.Port),\n\t\t}\n\t\tfor _, rawUser := range serverConfig.Users {\n\t\t\tuser := new(protocol.User)\n\t\t\tif v.Address != nil {\n\t\t\t\tuser.Level = v.Level\n\t\t\t\tuser.Email = v.Email\n\t\t\t} else {\n\t\t\t\tif err := json.Unmarshal(rawUser, user); err != nil {\n\t\t\t\t\treturn nil, errors.New(\"failed to parse HTTP user\").Base(err).AtError()\n\t\t\t\t}\n\t\t\t}\n\t\t\taccount := new(HTTPAccount)\n\t\t\tif v.Address != nil {\n\t\t\t\taccount.Username = v.Username\n\t\t\t\taccount.Password = v.Password\n\t\t\t} else {\n\t\t\t\tif err := json.Unmarshal(rawUser, account); err != nil {\n\t\t\t\t\treturn nil, errors.New(\"failed to parse HTTP account\").Base(err).AtError()\n\t\t\t\t}\n\t\t\t}\n\t\t\tuser.Account = serial.ToTypedMessage(account.Build())\n\t\t\tserver.User = user\n\t\t\tbreak\n\t\t}\n\t\tconfig.Server = server\n\t\tbreak\n\t}\n\tconfig.Header = make([]*http.Header, 0, 32)\n\tfor key, value := range v.Headers {\n\t\tconfig.Header = append(config.Header, &http.Header{\n\t\t\tKey:   key,\n\t\t\tValue: value,\n\t\t})\n\t}\n\treturn config, nil\n}","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/infra/conf/http.go#L91-L127","documentation":"Thrown when json.Unmarshal of a users entry into HTTPAccount fails. After parsing the protocol.User envelope, Xray unmarshals the same JSON object into HTTPAccount (username/password fields); if those fields have wrong types (e.g. username as a number) or the JSON is malformed, this error is returned with the parse error attached. Only hit on the servers[].users form.","triggerScenarios":"A users entry like {\"user\": 123} where the username field is numeric, or extra structure that breaks deserialization of username/password into strings.","commonSituations":"Using key names from other ecosystems (e.g. \"user\" vs expected account field names) combined with wrong value types; templating bugs injecting non-string credentials.","solutions":["Ensure username and password in each users entry are JSON strings","Use the documented field names for HTTP outbound users","Validate the raw JSON with jq before starting Xray"],"exampleFix":"// before\n\"users\": [ { \"user\": 123, \"pass\": \"x\" } ]\n// after\n\"users\": [ { \"user\": \"123\", \"pass\": \"x\" } ]","handlingStrategy":"validation","validationCode":"var probe struct {\n\tUsername string `json:\"user\"`\n\tPassword string `json:\"pass\"`\n}\nif err := json.Unmarshal(rawUser, &probe); err != nil {\n\treturn fmt.Errorf(\"HTTP account fields must be strings: %w\", err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always quote credentials in JSON even when they look numeric","Use the field names expected by Xray's HTTPAccount (user/pass per docs)"],"tags":["xray","config","http","json","parsing","auth"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}