File tree Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import (
13
13
"github.com/pkg/errors"
14
14
"github.com/tikv/client-go/v2/internal/logutil"
15
15
"github.com/tikv/client-go/v2/tikvrpc"
16
+ "github.com/tikv/client-go/v2/util/intest"
16
17
"github.com/tikv/client-go/v2/util/redact"
17
18
"go.uber.org/zap"
18
19
)
@@ -705,6 +706,14 @@ func (c *codecV2) EncodeKey(key []byte) []byte {
705
706
}
706
707
707
708
func (c * codecV2 ) DecodeKey (encodedKey []byte ) ([]byte , error ) {
709
+ if len (encodedKey ) == 0 {
710
+ if ! intest .InTest {
711
+ logutil .BgLogger ().Warn (
712
+ "codecV2.DecodeKey called with empty key. This shouldn't happen in prod" ,
713
+ zap .Stack ("stack" ))
714
+ }
715
+ return nil , nil
716
+ }
708
717
// If the given key does not start with the correct prefix,
709
718
// return out of bound error.
710
719
if ! bytes .HasPrefix (encodedKey , c .prefix ) {
Original file line number Diff line number Diff line change
1
+ // Copyright 2025 TiKV Authors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ //go:build intest
16
+
17
+ package intest
18
+
19
+ // InTest checks if the code is running in test.
20
+ var InTest = true
Original file line number Diff line number Diff line change
1
+ // Copyright 2025 TiKV Authors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ //go:build !intest
16
+
17
+ package intest
18
+
19
+ // InTest checks if the code is running in test.
20
+ var InTest = false
You can’t perform that action at this time.
0 commit comments