Skip to content

fix(string): add empty string value check for INCR to match Redis behavior#3354

Merged
git-hulk merged 1 commit into
apache:unstablefrom
sryanyuan:fix-incr-empty-key
Jan 29, 2026
Merged

fix(string): add empty string value check for INCR to match Redis behavior#3354
git-hulk merged 1 commit into
apache:unstablefrom
sryanyuan:fix-incr-empty-key

Conversation

@sryanyuan
Copy link
Copy Markdown
Contributor

Background

Previously, Kvrocks allowed INCR on a key whose value was an empty string (""),
treating it as zero and returning 1.

In Redis, the same operation results in an error:
ERR value is not an integer or out of range

This difference caused inconsistent behavior between Kvrocks and Redis.

Changes

  • Added check for empty string values before performing INCR
  • Return error when value is an empty string, matching Redis behavior

Result

Kvrocks now behaves consistently with Redis when performing INCR on empty string values,
improving compatibility and reducing unexpected results in client applications.

@sonarqubecloud
Copy link
Copy Markdown

@git-hulk git-hulk changed the title fix(string): Add empty string value check for INCR to match Redis behavior fix(string): add empty string value check for INCR to match Redis behavior Jan 29, 2026
@git-hulk git-hulk merged commit 4404eb7 into apache:unstable Jan 29, 2026
40 checks passed
nagisa-kunhah pushed a commit to nagisa-kunhah/kvrocks that referenced this pull request Apr 29, 2026
…avior (apache#3354)

### Background
Previously, Kvrocks allowed INCR on a key whose value was an empty
string (""),
treating it as zero and returning 1.

In Redis, the same operation results in an error:
ERR value is not an integer or out of range

This difference caused inconsistent behavior between Kvrocks and Redis.

### Changes
- Added check for empty string values before performing INCR
- Return error when value is an empty string, matching Redis behavior

### Result
Kvrocks now behaves consistently with Redis when performing INCR on
empty string values,
improving compatibility and reducing unexpected results in client
applications.

Co-authored-by: yxj25245 <yxj25245@ly.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants