Skip to content

Commit a85d36e

Browse files
authored
Merge pull request #1296 from RedisInsight/bugfix/RI-3650_status_error_on_big_key
Bugfix/ri 3650 status error on big key
2 parents 546b577 + 6d27e46 commit a85d36e

File tree

5 files changed

+61
-47
lines changed

5 files changed

+61
-47
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ lerna-debug.log*
1616
# Tests
1717
/coverage
1818
/.nyc_output
19+
**/coverage
1920

2021
# IDEs and editors
2122
/.idea

redisinsight/api/src/modules/browser/controllers/keys/keys.controller.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ export class KeysController extends BaseController {
4040
super();
4141
}
4242

43-
@Get('')
43+
@Post('')
44+
@HttpCode(200)
4445
@ApiOperation({ description: 'Get keys by cursor position' })
4546
@ApiRedisParams()
4647
@ApiOkResponse({
@@ -50,7 +51,7 @@ export class KeysController extends BaseController {
5051
@ApiQueryRedisStringEncoding()
5152
async getKeys(
5253
@Param('dbInstance') dbInstance: string,
53-
@Query() getKeysDto: GetKeysDto,
54+
@Body() getKeysDto: GetKeysDto,
5455
): Promise<GetKeysWithDetailsResponse[]> {
5556
return this.keysBusinessService.getKeys(
5657
{

redisinsight/api/test/api/keys/GET-instance-id-keys.test.ts renamed to redisinsight/api/test/api/keys/POST-instance-id-keys.test.ts

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const { server, request, constants, rte } = deps;
1515

1616
// endpoint to test
1717
const endpoint = (instanceId = constants.TEST_INSTANCE_ID) =>
18-
request(server).get(`/instance/${instanceId}/keys`);
18+
request(server).post(`/instance/${instanceId}/keys`);
1919

2020
const responseSchema = Joi.array().items(Joi.object().keys({
2121
total: Joi.number().integer().required(),
@@ -56,7 +56,7 @@ const isKeyInResponse = (body, keyName) => _.find(
5656
),
5757
)
5858

59-
describe('GET /instance/:instanceId/keys', () => {
59+
describe('POST /instance/:instanceId/keys', () => {
6060
// todo: add query validation
6161
xdescribe('Validation', () => {});
6262

@@ -68,7 +68,7 @@ describe('GET /instance/:instanceId/keys', () => {
6868
[
6969
{
7070
name: 'Should return all keys in utf-8 (by default)',
71-
query: {
71+
data: {
7272
count: 10_000,
7373
cursor: '0',
7474
},
@@ -81,6 +81,8 @@ describe('GET /instance/:instanceId/keys', () => {
8181
name: 'Should return all keys in utf-8',
8282
query: {
8383
encoding: 'utf8',
84+
},
85+
data: {
8486
count: 10_000,
8587
cursor: '0',
8688
},
@@ -93,6 +95,8 @@ describe('GET /instance/:instanceId/keys', () => {
9395
name: 'Should return all keys in ascii',
9496
query: {
9597
encoding: 'ascii',
98+
},
99+
data: {
96100
count: 10_000,
97101
cursor: '0',
98102
},
@@ -105,6 +109,8 @@ describe('GET /instance/:instanceId/keys', () => {
105109
name: 'Should return all keys in buffer',
106110
query: {
107111
encoding: 'buffer',
112+
},
113+
data: {
108114
count: 10_000,
109115
cursor: '0',
110116
},
@@ -126,7 +132,7 @@ describe('GET /instance/:instanceId/keys', () => {
126132
[
127133
{
128134
name: 'Should find key by exact name',
129-
query: {
135+
data: {
130136
cursor: '0',
131137
match: `${constants.TEST_RUN_ID}_str_key_1`
132138
},
@@ -153,7 +159,7 @@ describe('GET /instance/:instanceId/keys', () => {
153159
},
154160
{
155161
name: 'Should not find key by exact name',
156-
query: {
162+
data: {
157163
cursor: '0',
158164
match: 'not_exist_key'
159165
},
@@ -179,7 +185,7 @@ describe('GET /instance/:instanceId/keys', () => {
179185
},
180186
{
181187
name: 'Should prevent full scan in one request',
182-
query: {
188+
data: {
183189
count: 100,
184190
cursor: '0',
185191
match: 'not_exist_key*'
@@ -208,7 +214,7 @@ describe('GET /instance/:instanceId/keys', () => {
208214
},
209215
{
210216
name: 'Should search by with * in the end',
211-
query: {
217+
data: {
212218
cursor: '0',
213219
match: `${constants.TEST_RUN_ID}_str_key_11*`
214220
},
@@ -237,7 +243,7 @@ describe('GET /instance/:instanceId/keys', () => {
237243
},
238244
{
239245
name: 'Should search by with * in the beginning',
240-
query: {
246+
data: {
241247
cursor: '0',
242248
match: '*_key_111'
243249
},
@@ -266,7 +272,7 @@ describe('GET /instance/:instanceId/keys', () => {
266272
},
267273
{
268274
name: 'Should search by with * in the middle',
269-
query: {
275+
data: {
270276
cursor: '0',
271277
match: `${constants.TEST_RUN_ID}_str_*_111`
272278
},
@@ -293,7 +299,7 @@ describe('GET /instance/:instanceId/keys', () => {
293299
},
294300
{
295301
name: 'Should search by with ? in the end',
296-
query: {
302+
data: {
297303
cursor: '0',
298304
match: `${constants.TEST_RUN_ID}_str_key_10?`
299305
},
@@ -322,7 +328,7 @@ describe('GET /instance/:instanceId/keys', () => {
322328
},
323329
{
324330
name: 'Should search by with [a-b] glob pattern',
325-
query: {
331+
data: {
326332
cursor: '0',
327333
match: `${constants.TEST_RUN_ID}_str_key_10[0-5]`
328334
},
@@ -351,7 +357,7 @@ describe('GET /instance/:instanceId/keys', () => {
351357
},
352358
{
353359
name: 'Should search by with [a,b,c] glob pattern',
354-
query: {
360+
data: {
355361
cursor: '0',
356362
match: `${constants.TEST_RUN_ID}_str_key_10[0,1,2]`
357363
},
@@ -380,7 +386,7 @@ describe('GET /instance/:instanceId/keys', () => {
380386
},
381387
{
382388
name: 'Should search by with [abc] glob pattern',
383-
query: {
389+
data: {
384390
cursor: '0',
385391
match: `${constants.TEST_RUN_ID}_str_key_10[012]`
386392
},
@@ -409,7 +415,7 @@ describe('GET /instance/:instanceId/keys', () => {
409415
},
410416
{
411417
name: 'Should search by with [^a] glob pattern',
412-
query: {
418+
data: {
413419
cursor: '0',
414420
match: `${constants.TEST_RUN_ID}_str_key_10[^0]`
415421
},
@@ -438,7 +444,7 @@ describe('GET /instance/:instanceId/keys', () => {
438444
},
439445
{
440446
name: 'Should search by with combined glob patterns',
441-
query: {
447+
data: {
442448
cursor: '0',
443449
match: `${constants.TEST_RUN_ID}_s?r_*_[1][0-5][^0]`
444450
},
@@ -470,7 +476,7 @@ describe('GET /instance/:instanceId/keys', () => {
470476
[
471477
{
472478
name: 'Should scan all types',
473-
query: {
479+
data: {
474480
cursor: '0',
475481
},
476482
responseSchema,
@@ -483,7 +489,7 @@ describe('GET /instance/:instanceId/keys', () => {
483489
},
484490
{
485491
name: 'Should scan by provided count value',
486-
query: {
492+
data: {
487493
count: 500,
488494
cursor: '0',
489495
},
@@ -517,7 +523,7 @@ describe('GET /instance/:instanceId/keys', () => {
517523
while (cursor !== 0) {
518524
await validateApiCall({
519525
endpoint,
520-
query: {
526+
data: {
521527
cursor: cursor || 0,
522528
count: 99,
523529
},
@@ -542,7 +548,7 @@ describe('GET /instance/:instanceId/keys', () => {
542548
[
543549
{
544550
name: 'Should filter by type (string)',
545-
query: {
551+
data: {
546552
cursor: '0',
547553
type: 'string',
548554
count: 200,
@@ -562,7 +568,7 @@ describe('GET /instance/:instanceId/keys', () => {
562568
},
563569
{
564570
name: 'Should filter by type (list)',
565-
query: {
571+
data: {
566572
cursor: '0',
567573
type: 'list',
568574
count: 200,
@@ -582,7 +588,7 @@ describe('GET /instance/:instanceId/keys', () => {
582588
},
583589
{
584590
name: 'Should filter by type (set)',
585-
query: {
591+
data: {
586592
cursor: '0',
587593
type: 'set',
588594
count: 200,
@@ -602,7 +608,7 @@ describe('GET /instance/:instanceId/keys', () => {
602608
},
603609
{
604610
name: 'Should filter by type (zset)',
605-
query: {
611+
data: {
606612
cursor: '0',
607613
type: 'zset',
608614
count: 200,
@@ -622,7 +628,7 @@ describe('GET /instance/:instanceId/keys', () => {
622628
},
623629
{
624630
name: 'Should filter by type (hash)',
625-
query: {
631+
data: {
626632
cursor: '0',
627633
type: 'hash',
628634
count: 200,
@@ -649,7 +655,7 @@ describe('GET /instance/:instanceId/keys', () => {
649655
[
650656
{
651657
name: 'Should filter by type (ReJSON-RL)',
652-
query: {
658+
data: {
653659
cursor: '0',
654660
type: 'ReJSON-RL',
655661
count: 200,
@@ -675,7 +681,7 @@ describe('GET /instance/:instanceId/keys', () => {
675681
[
676682
{
677683
name: 'Should filter by type (timeseries)',
678-
query: {
684+
data: {
679685
cursor: '0',
680686
type: 'TSDB-TYPE',
681687
count: 200,
@@ -701,7 +707,7 @@ describe('GET /instance/:instanceId/keys', () => {
701707
[
702708
{
703709
name: 'Should filter by type (stream)',
704-
query: {
710+
data: {
705711
cursor: '0',
706712
type: 'stream',
707713
count: 200,
@@ -727,7 +733,7 @@ describe('GET /instance/:instanceId/keys', () => {
727733
[
728734
{
729735
name: 'Should filter by type (stream)',
730-
query: {
736+
data: {
731737
cursor: '0',
732738
type: 'graphdata',
733739
count: 200,
@@ -754,7 +760,7 @@ describe('GET /instance/:instanceId/keys', () => {
754760
[
755761
{
756762
name: 'Should scan all types',
757-
query: {
763+
data: {
758764
cursor: '0',
759765
},
760766
responseSchema,
@@ -780,7 +786,7 @@ describe('GET /instance/:instanceId/keys', () => {
780786
},
781787
{
782788
name: 'Should scan by provided count value',
783-
query: {
789+
data: {
784790
count: 300,
785791
cursor: '0',
786792
},
@@ -813,7 +819,7 @@ describe('GET /instance/:instanceId/keys', () => {
813819
while (cursor.length > 0) {
814820
await validateApiCall({
815821
endpoint,
816-
query: {
822+
data: {
817823
cursor: cursor.join('||'),
818824
count: 99,
819825
},
@@ -840,7 +846,7 @@ describe('GET /instance/:instanceId/keys', () => {
840846
[
841847
{
842848
name: 'Should filter by type (string)',
843-
query: {
849+
data: {
844850
cursor: '0',
845851
type: 'string',
846852
count: 200,
@@ -878,7 +884,7 @@ describe('GET /instance/:instanceId/keys', () => {
878884
[
879885
{
880886
name: 'check keyname with non-ASCII symbols should be properly listed',
881-
query: {
887+
data: {
882888
cursor: '0',
883889
count: 200,
884890
},
@@ -908,7 +914,7 @@ describe('GET /instance/:instanceId/keys', () => {
908914
[
909915
{
910916
name: 'Should scan all types',
911-
query: {
917+
data: {
912918
cursor: '0',
913919
match: key
914920
},
@@ -933,15 +939,15 @@ describe('GET /instance/:instanceId/keys', () => {
933939
{
934940
name: 'Should remove key',
935941
endpoint: () => endpoint(constants.TEST_INSTANCE_ACL_ID),
936-
query: {
942+
data: {
937943
cursor: '0',
938944
},
939945
statusCode: 200,
940946
},
941947
{
942948
name: 'Should throw error if no permissions for "scan" command',
943949
endpoint: () => endpoint(constants.TEST_INSTANCE_ACL_ID),
944-
query: {
950+
data: {
945951
cursor: '0',
946952
},
947953
statusCode: 403,

0 commit comments

Comments
 (0)