{"record":{"id":"129ad555f8c9ae10","repo":"XTLS/Xray-core","slug":"invalid-value-basekey-must-be-32-bytes","errorCode":null,"errorMessage":": invalid value (BaseKey must be 32 bytes): ","messagePattern":": invalid value \\(BaseKey must be 32 bytes\\): ","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/xudp/xudp.go","lineNumber":43,"sourceCode":"\tprotocol.AddressFamilyByte(byte(protocol.AddressTypeIPv6), net.AddressFamilyIPv6),\n\tprotocol.PortThenAddress(),\n)\n\nvar (\n\tShow    atomic.Bool\n\tbaseKey atomic.Value\n)\n\nfunc reloadEnvSettings() error {\n\tShow.Store(strings.ToLower(platform.NewEnvFlag(platform.XUDPLog).GetValue(func() string { return \"\" })) == \"true\")\n\traw := platform.NewEnvFlag(platform.XUDPBaseKey).GetValue(func() string { return \"\" })\n\tif raw == \"\" {\n\t\tensureBaseKey()\n\t\treturn nil\n\t}\n\tkey, _ := base64.RawURLEncoding.DecodeString(raw)\n\tif len(key) != 32 {\n\t\treturn errors.New(platform.XUDPBaseKey + \": invalid value (BaseKey must be 32 bytes): \" + raw + \" len \" + strconv.Itoa(len(key)))\n\t}\n\tbaseKey.Store(append([]byte(nil), key...))\n\treturn nil\n}\n\nfunc ensureBaseKey() []byte {\n\tif key := baseKey.Load(); key != nil {\n\t\treturn key.([]byte)\n\t}\n\tkey := make([]byte, 32)\n\tif _, err := rand.Read(key); err != nil {\n\t\tpanic(err)\n\t}\n\tbaseKey.Store(key)\n\treturn key\n}\n\nfunc init() {","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/common/xudp/xudp.go#L25-L61","documentation":"Error \": invalid value (BaseKey must be 32 bytes): \" thrown in XTLS/Xray-core.","triggerScenarios":"Thrown at common/xudp/xudp.go:43 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}