{"record":{"id":"c9111442c8a3b20f","repo":"gravitational/teleport","slug":"too-large-v","errorCode":null,"errorMessage":"too large: %v","messagePattern":"too large: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"api/utils/grpc/size.go","lineNumber":83,"sourceCode":"\t\t}\n\t\tlastDigit++\n\t}\n\n\tnum := s[:lastDigit]\n\n\tvar value float32\n\tif f, err := strconv.ParseFloat(num, 32); err == nil {\n\t\tvalue = float32(f)\n\t} else {\n\t\treturn 0, err\n\n\t}\n\n\textra := strings.ToLower(strings.TrimSpace(s[lastDigit:]))\n\tif m, ok := bytesSizeTable[extra]; ok {\n\t\tvalue *= float32(m)\n\t\tif value >= math.MaxInt32 {\n\t\t\treturn 0, fmt.Errorf(\"too large: %v\", s)\n\t\t}\n\t\treturn int(value), nil\n\t}\n\n\treturn 0, fmt.Errorf(\"unhandled size name: %v\", extra)\n}\n\n// MaxClientRecvMsgSize returns maximum message size in bytes the client can receive.\n//\n// By default 4MB is returned, to overwrite this, set `TELEPORT_UNSTABLE_GRPC_RECV_SIZE` envriroment\n// variable. If the value cannot be parsed or exceeds int32 limits, the default value is returned.\n//\n// The result of this call can be passed directly into `grpc.MaxCallRecvMsgSize`, example:\n//\n//\tconn, err := grpc.DialContext(ctx, target,\n//\t\tgrpc.WithDefaultCallOptions(\n//\t\t\tgrpc.MaxCallRecvMsgSize(grpcutils.MaxClientRecvMsgSize()),\n//\t\t),","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/gravitational/teleport/blob/1283425b60ec5f60d509ba4c791183d452923ff7/api/utils/grpc/size.go#L65-L101","documentation":"parseBytes parses a human-readable byte size like '24mb' into an int. After multiplying the numeric part by the unit multiplier, if the resulting value is >= math.MaxInt32 it cannot safely fit in an int32-sized gRPC message size, so parseBytes rejects it with 'too large'. This guards against integer overflow when callers like MaxClientRecvMsgSize pass the result to grpc.MaxCallRecvMsgSize.","triggerScenarios":"Setting TELEPORT_UNSTABLE_GRPC_RECV_SIZE to a value whose numeric value times the unit multiplier reaches or exceeds 2147483647, e.g. '3gb' (3000000000), '2.5gib' (2684354560), or '3000000000b'.","commonSituations":"An operator sets the env var to '4g' or '10gb' hoping to raise the gRPC receive limit, not realizing the parser caps at int32; the error is silently swallowed by MaxClientRecvMsgSize which falls back to the 4MB default.","solutions":["Set TELEPORT_UNSTABLE_GRPC_RECV_SIZE to a value below 2GiB, e.g. '2147483647' or '2gib' minus 1","Remove the env var entirely to use the 4MB default","If you truly need >2GB gRPC messages, that is unsupported by this parser; reduce message sizes instead (chunk/paginate payloads)"],"exampleFix":"// before\nexport TELEPORT_UNSTABLE_GRPC_RECV_SIZE=5gib\n// after\nexport TELEPORT_UNSTABLE_GRPC_RECV_SIZE=2gib  # or 2147483647","handlingStrategy":"validation","validationCode":"func validRecvSize(v string) bool {\n\ts, err := grpcutils.ParseBytesPublic(v) // or replicate: parse number + unit, reject >= math.MaxInt32\n\treturn err == nil && s > 0 && s < math.MaxInt32\n}\n// check before setting: validRecvSize(os.Getenv(\"TELEPORT_UNSTABLE_GRPC_RECV_SIZE\"))","typeGuard":null,"tryCatchPattern":"// Go: no panic possible; MaxClientRecvMsgSize already falls back to default\nsize := grpcutils.MaxClientRecvMsgSize()\nif size == 4*1024*1024 && os.Getenv(\"TELEPORT_UNSTABLE_GRPC_RECV_SIZE\") != \"\" {\n\tlog.Warnf(\"TELEPORT_UNSTABLE_GRPC_RECV_SIZE rejected, using 4MB default\")\n}","preventionTips":["Keep TELEPORT_UNSTABLE_GRPC_RECV_SIZE under 2GiB (int32 max is 2147483647)","Remember MaxClientRecvMsgSize silently swallows parse errors and falls back to 4MB — log the env var at startup","Prefer 'mib'/'gib' binary units and verify the effective value once at boot"],"tags":["grpc","configuration","integer-overflow","env-var"],"backgroundTag":"grpc-message-size-limit","analyzedSha":"1283425b60ec5f60d509ba4c791183d452923ff7","analyzedAt":"2026-09-02T04:06:41.601Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}