{"record":{"id":"06c9108a13d771c3","repo":"XTLS/Xray-core","slug":"too-long-shortids","errorCode":null,"errorMessage":"too long \"shortIds[","messagePattern":"too long \"shortIds\\[","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"infra/conf/transport_security.go","lineNumber":141,"sourceCode":"\t\t\tvar u uint64\n\t\t\tfor i, s := range strings.Split(c.MaxClientVer, \".\") {\n\t\t\t\tif i == 3 {\n\t\t\t\t\treturn nil, errors.New(`invalid \"maxClientVer\": `, c.MaxClientVer)\n\t\t\t\t}\n\t\t\t\tif u, err = strconv.ParseUint(s, 10, 8); err != nil {\n\t\t\t\t\treturn nil, errors.New(`\"maxClientVer[`, i, `]\" should be less than 256`)\n\t\t\t\t} else {\n\t\t\t\t\tconfig.MaxClientVer[i] = byte(u)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif len(c.ShortIds) == 0 {\n\t\t\treturn nil, errors.New(`empty \"shortIds\"`)\n\t\t}\n\t\tconfig.ShortIds = make([][]byte, len(c.ShortIds))\n\t\tfor i, s := range c.ShortIds {\n\t\t\tif len(s) > 16 {\n\t\t\t\treturn nil, errors.New(`too long \"shortIds[`, i, `]\": `, s)\n\t\t\t}\n\t\t\tconfig.ShortIds[i] = make([]byte, 8)\n\t\t\tif _, err = hex.Decode(config.ShortIds[i], []byte(s)); err != nil {\n\t\t\t\treturn nil, errors.New(`invalid \"shortIds[`, i, `]\": `, s)\n\t\t\t}\n\t\t}\n\t\tconfig.Dest = s\n\t\tconfig.Type = c.Type\n\t\tconfig.Xver = c.Xver\n\t\tconfig.ServerNames = c.ServerNames\n\t\tconfig.MaxTimeDiff = c.MaxTimeDiff\n\n\t\tif c.Mldsa65Seed != \"\" {\n\t\t\tif c.Mldsa65Seed == c.PrivateKey {\n\t\t\t\treturn nil, errors.New(`\"mldsa65Seed\" and \"privateKey\" can not be the same value: `, c.Mldsa65Seed)\n\t\t\t}\n\t\t\tif config.Mldsa65Seed, err = base64.RawURLEncoding.DecodeString(c.Mldsa65Seed); err != nil || len(config.Mldsa65Seed) != 32 {\n\t\t\t\treturn nil, errors.New(`invalid \"mldsa65Seed\": `, c.Mldsa65Seed)","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/infra/conf/transport_security.go#L123-L159","documentation":"Thrown by the REALITY builder when a shortId string is longer than 16 characters. Short IDs are hex-encoded 8-byte values; 16 hex chars is the maximum, and the string is later hex-decoded into an 8-byte buffer. The message includes the index and the offending value (assembled from multiple parts in errors.New).","triggerScenarios":"Setting a shortId like \"0123456789abcdef0\" (17+ chars), or pasting a UUID or random base64 blob into the field.","commonSituations":"Generating tokens with uuidgen or openssl rand -base64 instead of hex, or concatenating two shortIds by accident.","solutions":["Use 0-16 hex characters, e.g. \"6ba85179e30d4fc2\".","Generate with 'openssl rand -hex 8' (or fewer bytes) if you need randomness.","Note odd-length hex strings also fail the later hex.Decode (invalid shortIds[i]) — keep the length even."],"exampleFix":"// before\n\"shortIds\": [\"6ba85179e30d4fc2-extra\"]\n// after\n\"shortIds\": [\"6ba85179e30d4fc2\"]","handlingStrategy":"validation","validationCode":"for i, id := range reality.ShortIds {\n    if len(id) > 16 || len(id)%2 != 1 && !isHex(id) { /* check */ }\n}\n// simpler strict form:\nvar shortIdRe = regexp.MustCompile(`^([0-9a-fA-F]{2})*$`)\nfunc validShortId(s string) bool { return len(s) <= 16 && shortIdRe.MatchString(s) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Generate shortIds with 'openssl rand -hex N' where N <= 8.","Never paste UUIDs or base64 strings into shortIds."],"tags":["config","reality","shortid","hex","validation","go"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}