Repository: DiceDB/dice (Go)

Issue:
Inconsistent `GETEX`: GETEX with big integer should report an error
## Steps to reproduce

Run the commands mentioned in the test on Line 98 in the file https://github.com/AshwinKul28/dice-tests/tree/main/tcltests/unit/expire.tcl#L98.

## Expected output

The expected output when the above set of commands when run on Redis

```
ERR invalid expire time in 'getex' command
```

## Observed output

The observed output when the above set of commands when run on DiceDB

```
bar
```

The steps to run the test cases are mentioned in the README of the [dice-tests repository](https://github.com/AshwinKul28/dice-tests).


## Expectations for resolution

This issue will be considered resolved when the following things are done

1. changes in the [`dice`](https://github.com/dicedb/dice) code to meet the expected behavior
2. Successful run of the tcl test behavior

You can find the tests under the `tests` directory of the [`dice`](https://github.com/dicedb/dice) repository and the steps to run are in the [README file](https://github.com/dicedb/dice). Refer to the following links to set up DiceDB and Redis 7.2.5 locally

- [setup DiceDB locally](https://github.com/dicedb/dice)
- [setup Redis 7.2.5 locally](https://gist.github.com/arpitbbhayani/94aedf279349303ed7394197976b6843)
- [setup DiceDB CLI](https://github.com/dicedb/dice)


Discussion:
Hey @AshwinKul28 👋, I'd like to work on this issue. Could you please assign it to me?
@yashvardhan-verma assigned, thanks for picking this up.

@AshwinKul28  @lucifercr07  can you assign me this issue i have fixed this issue.
@yashvardhan-verma Thanks for picking this up, but if you haven't started on it yet then @Gaurav-Kumar81 already have a solution on it. We can assign him and @yashvardhan-verma you can pick up any other issue. Let me know. thanks

Sure, you can @AshwinKul28 



Patch:
diff --git a/internal/eval/eval.go b/internal/eval/eval.go
index 552423ff3..43ec870bc 100644
--- a/internal/eval/eval.go
+++ b/internal/eval/eval.go
@@ -1912,7 +1912,7 @@ func evalGETEX(args []string, store *dstore.Store) []byte {
 			if err != nil {
 				return diceerrors.NewErrWithMessage(diceerrors.IntOrOutOfRangeErr)
 			}
-			if exDuration <= 0 {
+			if exDuration <= 0 || exDuration > maxExDuration {
 				return diceerrors.NewErrExpireTime("GETEX")
 			}
 


Test patch:
diff --git a/internal/eval/eval_test.go b/internal/eval/eval_test.go
index ea8e27102..9dab11e9a 100644
--- a/internal/eval/eval_test.go
+++ b/internal/eval/eval_test.go
@@ -65,6 +65,7 @@ func TestEval(t *testing.T) {
 	testEvalHLEN(t, store)
 	testEvalSELECT(t, store)
 	testEvalLLEN(t, store)
+	testEvalGETEX(t, store)
 }
 
 func testEvalPING(t *testing.T, store *dstore.Store) {
@@ -122,6 +123,37 @@ func testEvalSET(t *testing.T, store *dstore.Store) {
 	runEvalTests(t, tests, evalSET, store)
 }
 
+func testEvalGETEX(t *testing.T, store *dstore.Store) {
+	tests := map[string]evalTestCase{
+
+		"key val pair and valid EX": {
+			setup: func() {
+				key := "foo"
+				value := "bar"
+				obj := &object.Obj{
+					Value: value,
+				}
+				store.Put(key, obj)
+			},
+			input:  []string{"foo", Ex, "10"},
+			output: clientio.Encode("bar", false),
+		},
+		"key val pair and invalid EX": {
+			setup: func() {
+				key := "foo"
+				value := "bar"
+				obj := &object.Obj{
+					Value: value,
+				}
+				store.Put(key, obj)
+			},
+			input:  []string{"foo", Ex, "10000000000000000"},
+			output: []byte("-ERR invalid expire time in 'getex' command\r\n")},
+	}
+
+	runEvalTests(t, tests, evalGETEX, store)
+}
+
 func testEvalMSET(t *testing.T, store *dstore.Store) {
 	tests := map[string]evalTestCase{
 		"nil value":         {input: nil, output: []byte("-ERR wrong number of arguments for 'mset' command\r\n")},