@@ -29,12 +29,13 @@ const validInputData = {
2929 keyName : constants . getRandomString ( ) ,
3030} ;
3131
32- // ARNEXT returns nil when the insertion cursor is exhausted (toIndexString
33- // passes the nil through as JSON null), so index is string | null.
32+ // Service issues ARLEN (which returns max_index + 1 as a u64) and maps the
33+ // reply through toRequiredIndexString, so `index` is always a decimal string
34+ // — never null, never numeric.
3435const responseSchema = Joi . object ( )
3536 . keys ( {
3637 keyName : JoiRedisString . required ( ) ,
37- index : Joi . string ( ) . pattern ( / ^ \d + $ / ) . allow ( null ) . required ( ) ,
38+ index : Joi . string ( ) . pattern ( / ^ \d + $ / ) . required ( ) ,
3839 } )
3940 . required ( ) ;
4041
@@ -71,8 +72,9 @@ describe('POST /databases/:instanceId/array/get-next-index', () => {
7172 const keyName = constants . getRandomString ( ) ;
7273 await rte . client . call ( 'ARMSET' , keyName , '0' , 'a' , '1' , 'b' , '5' , 'c' ) ;
7374
74- // Insertion cursor advances past the highest set index, not just the
75- // populated count — ARNEXT must follow ARLEN, not ARCOUNT.
75+ // ARLEN returns max_index + 1, so the next safe write index for an
76+ // array with the highest populated slot at 5 is 6 — locks in that the
77+ // endpoint surfaces length semantics, not the populated-slot count.
7678 await validateApiCall ( {
7779 endpoint,
7880 data : { keyName } ,
@@ -131,16 +133,18 @@ describe('POST /databases/:instanceId/array/get-next-index', () => {
131133 } ,
132134 } ,
133135 {
134- name : 'Should throw error if no permissions for "arnext " command' ,
136+ name : 'Should throw error if no permissions for "arlen " command' ,
135137 endpoint : aclEndpoint ,
136138 data : { keyName : aclKey } ,
137139 statusCode : 403 ,
138140 responseBody : { statusCode : 403 , error : 'Forbidden' } ,
139141 // beforeEach() wipes the key between tests; reseed via the root
140- // client (ACL rules below only affect the API request).
142+ // client (ACL rules below only affect the API request). The endpoint
143+ // is /get-next-index but the service now issues ARLEN, so the denial
144+ // must target -arlen (not -arnext).
141145 before : async ( ) => {
142146 await rte . client . call ( 'ARSET' , aclKey , '0' , 'x' ) ;
143- await rte . data . setAclUserRules ( '~* +@all -arnext ' ) ;
147+ await rte . data . setAclUserRules ( '~* +@all -arlen ' ) ;
144148 } ,
145149 } ,
146150 ] . map ( mainCheckFn ) ;
0 commit comments