Skip to content

LCS command broken for non String codecs - #3919

Merged
a-TODO-rov merged 7 commits into
redis:mainfrom
Dgramada:lcs-command-broken-for-non-string-codec
Sep 24, 2026
Merged

a-TODO-rov merged 7 commits into
redis:mainfrom
Dgramada:lcs-command-broken-for-non-string-codec

Conversation

@Dgramada

@Dgramada Dgramada commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

The LCS command currently expects only String values as keys and its output class only decodes String objects. This breaks the API for any user that wants to use something different from String.

A perfect example would be if someone decides to use ByteArrayCodec.INSTANCE. The output class will try to decode it as a String and throw a ClassCastException even though this is a perfectly viable use case.

Furthermore, having a single overload that calls only a single LcsArgs does not accurately represent the LCS command. Passing the keys as a vararg field introduces bugs. Developers can add as many keys as they want when in reality the Redis commands accepts only 2.

This PR introduces two new overloads that correctly represent the Redis command and deprecates the old method. It also handles the broken parser for the method which casts values to String.


Note

Medium Risk
Public API additions and deprecations change how LCS keys are encoded and routed in cluster; callers on the old LcsArgs.keys() path keep prior (broken) behavior until they migrate.

Overview
Fixes Redis LCS for non-String key codecs and cluster routing by adding lcs(key1, key2) and lcs(key1, key2, LcsArgs) across sync, async, reactive, cluster node-selection, and Kotlin coroutine APIs. Keys are sent via addKey() so they use the connection’s key codec and expose the first key for slot routing; the two-key overload returns the substring as V via ValueOutput.

LcsArgs is now modifiers-only: new LcsArgs.Builder helpers (justLen(), withIdx(), minMatchLen(), withMatchLen()), while lcs(LcsArgs), LcsArgs.Builder.keys(), and LcsArgs.by() are deprecated with validation in RedisCommandBuilder to prevent mixing key styles. StringMatchResultOutput no longer assumes String keys when decoding the match bulk string, fixing ClassCastException with codecs like ByteArrayCodec and compressed value codecs.

Docs and tests cover RESP encoding, cluster first-key exposure, integration scenarios, and deprecated-arg compatibility.

Reviewed by Cursor Bugbot for commit 0600271. Bugbot is set up for automated code reviews on this repo. Configure here.

Signed-off-by: yordantsintsov <yordan.tsintsov@gmail.com>
@Dgramada
Dgramada requested a review from a-TODO-rov September 16, 2026 14:12

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 951b20104e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Signed-off-by: yordantsintsov <yordan.tsintsov@gmail.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 664838eb4a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit b69fab7. Configure here.

@a-TODO-rov a-TODO-rov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@a-TODO-rov
a-TODO-rov merged commit a1bbe2d into redis:main Sep 24, 2026
9 of 10 checks passed
@Dgramada
Dgramada deleted the lcs-command-broken-for-non-string-codec branch September 24, 2026 13:57
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.

2 participants

⌂ 换网址