git-hulk commented on code in PR #308:
URL: 
https://github.com/apache/kvrocks-controller/pull/308#discussion_r2083120149


##########
store/slot.go:
##########
@@ -91,15 +91,30 @@ func (slotRange *SlotRange) MarshalJSON() ([]byte, error) {
 }
 
 func (slotRange *SlotRange) UnmarshalJSON(data []byte) error {
-       var slotsString string
+       var slotsString any
        if err := json.Unmarshal(data, &slotsString); err != nil {
                return err
        }
-       slotObject, err := ParseSlotRange(slotsString)
-       if err != nil {
-               return err
+       switch t := slotsString.(type) {
+       case string:
+               slotObject, err := ParseSlotRange(t)
+               if err != nil {
+                       return err
+               }
+               *slotRange = *slotObject
+       case float64:
+               // We use integer to represent the slot because we don't 
support the slot range
+               // in the past. So we need to support the integer type for 
backward compatibility.
+               // But the number in JSON is float64, so we need to convert it 
to int here.
+               if t < MinSlotID || t > MaxSlotID {
+                       return ErrSlotOutOfRange

Review Comment:
   > Sorry about this bug, I probably won't have time tomorrow to work on this, 
but I have some time on Sunday if you'd like me to make the changes
   
   @bseto  OK, you're right that it will become a null value after changing to 
the slot range. And I'm good with adding a dedicated new type for migrating 
slots. I will close this PR and wait for yours.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to