{"record":{"id":"4e746598a1a2cfee","repo":"XTLS/Xray-core","slug":"parse-config","errorCode":null,"errorMessage":"parse config","messagePattern":"parse config","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/shadowsocks_2022/inbound_multi.go","lineNumber":76,"sourceCode":"\t\t\tuser.Email = \"unnamed-user-\" + strconv.Itoa(i) + \"-\" + u.String()\n\t\t}\n\t\tu, err := user.ToMemoryUser()\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(\"failed to get shadowsocks user\").Base(err).AtError()\n\t\t}\n\t\tmemUsers = append(memUsers, u)\n\t}\n\n\tinbound := &MultiUserInbound{\n\t\tnetworks: networks,\n\t\tusers:    memUsers,\n\t}\n\tif config.Key == \"\" {\n\t\treturn nil, errors.New(\"missing key\")\n\t}\n\tpsk, err := base64.StdEncoding.DecodeString(config.Key)\n\tif err != nil {\n\t\treturn nil, errors.New(\"parse config\").Base(err)\n\t}\n\tservice, err := shadowaead_2022.NewMultiService[int](config.Method, psk, 500, inbound, nil)\n\tif err != nil {\n\t\treturn nil, errors.New(\"create service\").Base(err)\n\t}\n\terr = service.UpdateUsersWithPasswords(\n\t\tC.MapIndexed(memUsers, func(index int, it *protocol.MemoryUser) int { return index }),\n\t\tC.Map(memUsers, func(it *protocol.MemoryUser) string { return it.Account.(*MemoryAccount).Key }),\n\t)\n\tif err != nil {\n\t\treturn nil, errors.New(\"create service\").Base(err)\n\t}\n\n\tinbound.service = service\n\treturn inbound, nil\n}\n\n// AddUser implements proxy.UserManager.AddUser().","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/proxy/shadowsocks_2022/inbound_multi.go#L58-L94","documentation":"Raised when the inbound-level `key` string fails standard base64 (StdEncoding) decoding during multi-user 2022 inbound construction. Shadowsocks-2022 keys must be base64-encoded raw bytes; any illegal character, bad padding, or URL-safe-base64 input (-/_ instead of +//) is rejected.","triggerScenarios":"config.Key contains characters outside the standard base64 alphabet, incorrect '=' padding, or was encoded with urlsafe base64; also whitespace/newlines pasted from key generators.","commonSituations":"Copying keys that wrap across lines in terminals; keys generated by tools that emit urlsafe base64; stray quotes/spaces from manual editing.","solutions":["Regenerate the key with `openssl rand -base64 32` (or 16) and paste it as a single line.","If your source is urlsafe base64, re-encode to standard: translate -_ to +/ and fix padding.","Trim whitespace/newlines when scripting config generation."],"exampleFix":"# before (urlsafe characters)\n\"key\": \"abc-def_ghi\"\n# after\n\"key\": \"$(openssl rand -base64 32 | tr -d '\\n')\"","handlingStrategy":"validation","validationCode":"func isStdBase64(s string) bool {\n  _, err := base64.StdEncoding.DecodeString(strings.TrimSpace(s))\n  return err == nil\n}","typeGuard":"func isStdBase64(s string) bool { _, err := base64.StdEncoding.DecodeString(s); return err == nil }","tryCatchPattern":"psk, err := base64.StdEncoding.DecodeString(config.Key)\nif err != nil {\n  return fmt.Errorf(\"key must be standard base64 (no urlsafe chars/newlines): %w\", err)\n}","preventionTips":["Generate keys with openssl rand -base64 and strip newlines.","Paste keys as a single line; avoid terminals that wrap with inserted characters.","Reject urlsafe base64 at config-load time."],"tags":["shadowsocks-2022","base64","config","encoding","psk"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}