{"record":{"id":"55d40c544d1e12e8","repo":"vitessio/vitess","slug":"limit-v-exceeds-maximum-allowed-value-v","errorCode":null,"errorMessage":"limit %v exceeds maximum allowed value %v","messagePattern":"limit (.+?) exceeds maximum allowed value (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/grpcvtctldserver/server.go","lineNumber":1552,"sourceCode":"\n\tbs, err := backupstorage.GetBackupStorage()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer bs.Close()\n\n\tbucket := filepath.Join(req.Keyspace, req.Shard)\n\tspan.Annotate(\"backup_path\", bucket)\n\n\tbhs, err := bs.ListBackups(ctx, bucket)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttotalBackups := len(bhs)\n\tif req.Limit > 0 {\n\t\tif req.Limit > maxBackupLimit {\n\t\t\treturn nil, fmt.Errorf(\"limit %v exceeds maximum allowed value %v\", req.Limit, maxBackupLimit)\n\t\t}\n\t\tif int(req.Limit) < totalBackups {\n\t\t\ttotalBackups = int(req.Limit)\n\t\t}\n\t}\n\n\ttotalDetailedBackups := len(bhs)\n\tif req.DetailedLimit > 0 {\n\t\tif req.DetailedLimit > maxBackupLimit {\n\t\t\treturn nil, fmt.Errorf(\"detailed_limit %v exceeds maximum allowed value %v\", req.DetailedLimit, maxBackupLimit)\n\t\t}\n\t\tif int(req.DetailedLimit) < totalDetailedBackups {\n\t\t\ttotalDetailedBackups = int(req.DetailedLimit)\n\t\t}\n\t}\n\n\tbackups := make([]*mysqlctlpb.BackupInfo, 0, totalBackups)\n\tbackupsToSkip := len(bhs) - totalBackups","sourceCodeStart":1534,"sourceCodeEnd":1570,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/grpcvtctldserver/server.go#L1534-L1570","documentation":"GetBackups supports truncating the returned backup list via req.Limit, but caps it at maxBackupLimit to prevent excessive work. If req.Limit is greater than maxBackupLimit, the request is rejected with this error before listing backup handles.","triggerScenarios":"Calling GetBackups with a Limit field exceeding the server-defined maxBackupLimit constant (e.g. requesting millions of backups in one call).","commonSituations":"Clients passing an unbounded or default-large page size from generic pagination code; misconfigured scripts that set Limit to a sentinel like MaxInt32.","solutions":["Lower the Limit to a value at or below maxBackupLimit","Omit Limit (or set <= 0) to get the full untruncated list","Check the server constant maxBackupLimit in grpcvtctldserver for the allowed maximum"],"exampleFix":"// before\nreq.Limit = math.MaxInt32\n// after\nreq.Limit = 1000","handlingStrategy":"validation","validationCode":"const maxBackupLimit = 10000 // server-side cap\nif req.Limit > 0 && req.Limit > maxBackupLimit {\n    return fmt.Errorf(\"limit %d exceeds cap\", req.Limit)\n}","typeGuard":null,"tryCatchPattern":"_, err := client.GetBackups(ctx, req)\nif err != nil && strings.Contains(err.Error(), \"limit %v exceeds maximum\") {\n    req.Limit = 0 // fetch untruncated\n}","preventionTips":["Clamp client-side pagination to the documented server cap","Never use MaxInt sentinels for Limit","Omit Limit for full listings","Check maxBackupLimit in grpcvtctldserver when upgrading"],"tags":["vitess","backup","validation","pagination"],"backgroundTag":"limit-exceeds-maximum","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}