cockroachdb / cockroachdb/cockroach

cluster-settings: garbage error message for invalid byte-size value in SET CLUSTER SETTING

Open
#172,034 1 comment 0 reactions 0 assignees View on GitHub
A-configurability branch-master branch-release-26.3 C-bug O-agent O-qa T-db-server
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

**Describe the problem**

Setting a byte-size cluster setting to an invalid value returns an error
that leaks Go standard-library implementation details and doesn't tell
the user what was wrong or what format is expected.

**To Reproduce**

Affects all byte-size cluster settings; here using two as examples:

```sql
> SET CLUSTER SETTING sql.status.active_query_text.max_bytes = 'banana';
ERROR: strconv.ParseFloat: parsing "": invalid syntax

> SET CLUSTER SETTING bulkio.backup.file_size = 'not a size';
ERROR: strconv.ParseFloat: parsing "": invalid syntax

> SET CLUSTER SETTING bulkio.backup.file_size = '12X';
ERROR: unhandled size name: x
```

The error:

1. Mentions an empty parsed string `""` rather than the user's input.
2. Mentions a Go standard library function (`strconv.ParseFloat`) that
isn't relevant to the user.
3. Doesn't say what input formats are accepted (e.g. `1000 B`, `16 KiB`,
`1 MiB`).

**Expected behavior**

An error like:

```
ERROR: invalid byte-size value 'banana': expected a number with an
optional unit suffix (B, KiB, MiB, GiB, ...)
```

**Environment:**
- CockroachDB v26.3.0-beta.2-dev. Also reproduces in earlier versions —
this is pre-existing behavior in the byte-size setting parser, not
specific to any one setting.
- Client app: `cockroach sql`

**Additional context**

Discovered while QA-testing the new
`sql.status.active_query_text.max_bytes` setting in 26.3.

Jira issue: CRDB-65176

Contributor guide

Open the contributing guide

Research direction

Start at the byte-size setting parser used by SET CLUSTER SETTING and reproduce the invalid inputs shown in the issue. Trace how parsing errors are surfaced for byte-size cluster settings, then verify that invalid values report the user's input, describe accepted unit formats, and do not leak strconv or other implementation details.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.