pingcap / pingcap/tidb

tidb_redact_log is redacting even non-sensitive information for Error 3140 (Invalid JSON Text)

Open
#60,835 1 comment 0 reactions 1 assignee Claimed by @YangKeao View on GitHub
component/json severity/moderate sig/sql-infra type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)

```sql
use test;
create table j(j json not null);

/* FIRST CHECK THE ERROR MESSAGES WITHOUT REDACTION */

insert into j values ('');
-- ERROR 3140 (22032): Invalid JSON text: The document is empty
insert into j values ('xxx');
-- ERROR 3140 (22032): Invalid JSON text: The document root must not be followed by other values.
insert into j values ('9e9999');
-- ERROR 3140 (22032): Invalid JSON text: strconv.ParseFloat: parsing "9e9999": value out of range
insert into j values (concat(repeat('[', 301), repeat(']', 301)));
-- ERROR 3157 (22032): The JSON document exceeds the maximum depth.
```

### 2. What did you expect to see? (Required)

```sql
/* NOW ENABLE REDACTION, WE EXPECT TO SEE */

set @@tidb_redact_log = on;
insert into j values ('');
-- ERROR 3140 (22032): Invalid JSON text: The document is empty
insert into j values ('xxx');
-- ERROR 3140 (22032): Invalid JSON text: The document root must not be followed by other values.
insert into j values ('9e9999');
-- ERROR 3140 (22032): Invalid JSON text: strconv.ParseFloat: parsing "?": value out of range
insert into j values (concat(repeat('[', 301), repeat(']', 301)));
-- ERROR 3157 (22032): The JSON document exceeds the maximum depth.
```

### 3. What did you see instead (Required)

```sql
mysql> insert into j values ('');
ERROR 3140 (22032): Invalid JSON text: ?
mysql> insert into j values ('xxx');
ERROR 3140 (22032): Invalid JSON text: ?
mysql> insert into j values ('9e9999');
ERROR 3140 (22032): Invalid JSON text: ?
mysql> insert into j values (concat(repeat('[', 301), repeat(']', 301)));
ERROR 3157 (22032): The JSON document exceeds the maximum depth.
```

### 4. What is your TiDB version? (Required)

v8.5.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.