Skip to content

Fix RESP2 reply types in Redis adapter and proxy - #1263

Merged
bootjp merged 8 commits into
mainfrom
feature/redis-resp2-replies
Oct 14, 2026
Merged

bootjp merged 8 commits into
mainfrom
feature/redis-resp2-replies

Conversation

@bootjp

@bootjp bootjp commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Preserve RESP2 bulk-string values such as OK and PONG in parsed proxy replies, including nested arrays, and restore simple-string types for command metadata and transaction status replies.
  • Return the expected null-array and command metadata shapes from the proxy and ElasticKV Redis adapter.
  • Correct adapter PING arity, reject unsupported nonzero SELECT databases, and make XREAD without BLOCK return promptly.
  • Accept HELLO 2 without options in parsed proxy mode.
  • Restore simple-string replies for routed status commands, including MSET, PSETEX, RESTORE, PFMERGE, and XGROUP CREATE; align COMMAND DOCS groups with Redis 8.10.1.
  • Preserve status replies for admin subcommands including SLOWLOG RESET, MEMORY PURGE, ACL LOG RESET, SCRIPT DEBUG, and cluster operations, while keeping data-returning subcommands as bulk strings.
  • Preserve status replies for forwarded commands such as SAVE, BGSAVE, REPLICAOF, MIGRATE, and READWRITE; parse SET option operands so an IFEQ value of GET is not mistaken for the GET modifier.
  • Keep the simple-string PONG for argumentless PING inside EXEC while retaining bulk-string replies for PING message; return a simple-string OK for allowed ACL DRYRUN and a bulk-string explanation when denied.
  • Preserve DEBUG simple-string diagnostics and status replies, including the elements of DIGEST-VALUE; keep DEBUG PROTOCOL STRING and STRUCTSIZE as bulk strings.
  • Apply the same command-aware reply encoding after a Pub/Sub connection unsubscribes from every channel, including replies inside EXEC.
  • Preserve status-token replies nested inside EVAL, EVALSHA, and FCALL result arrays, while retaining bulk strings for other array elements.

Reproduction and validation

  • Compare GET of a value containing OK or PONG, COMMAND INFO GET, COMMAND DOCS GET, XREAD STREAMS missing 0, and blocking timeout replies through the proxy and adapter against Redis 8.10.1 in RESP2.
  • A temporary 108-case differential wire-type audit covered all 82 public adapter commands and the parsed proxy. Its remaining differences are listed below.
  • Compared COMMAND DOCS groups for all 82 public adapter commands against local Redis 8.10.1; regression tests also cover the two ElasticKV-only aliases.
  • go test ./adapter -run '^(TestRedis|TestCommand|TestParseXRead)' -count=1 -timeout=5m — passed.
  • go test ./proxy -count=1 — passed.
  • The proxy tests cover the SLOWLOG RESET admin path and status/data wire types for related subcommands.
  • Detached Pub/Sub session tests cover SET, GET, and mixed EXEC reply types after leaving subscription mode.
  • golangci-lint run ./... --timeout=5m — 0 issues.
  • git diff --check — passed.
  • go test ./adapter ./proxy -count=1 -timeout=10m — proxy passed; the broader adapter suite timed out after 10 minutes. The Redis/COMMAND tests above passed independently.

Known limits

  • A Lua bulk-string result whose contents equal a status token such as OK, QUEUED, or PONG can still be encoded as a simple string in parsed proxy mode, including inside arrays. Conversely, an arbitrary simple-string status outside those tokens can be encoded as a bulk string. The current go-redis result has already lost the original RESP string type; preserving it requires a lower-level reply path.
  • The same type loss leaves arbitrary module commands ambiguous when they return bulk data containing a status token such as OK. The default route retains its previous status-token behavior; full type fidelity for arbitrary commands requires a raw typed reply path.
  • ElasticKV exposes a subset of Redis command metadata. COMMAND INFO and COMMAND DOCS have the required RESP2 shape but less detail, COMMAND GETKEYSANDFLAGS is unsupported, and the command and module lists reflect supported features.
  • RESP3 and HELLO 2 options remain unsupported in parsed proxy mode.

Risk

  • Clients that relied on the previous incorrect RESP2 types will observe corrected types. Adapter SELECT now reports an error for nonzero databases instead of silently using database 0.

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2fc5ea2e-7ffe-460c-a1c7-5e0afce0eeb9
📥 Commits

Reviewing files that changed from the base of the PR and between fa84a87 and ab86507.

📒 Files selected for processing (4)
  • proxy/proxy.go
  • proxy/pubsub.go
  • proxy/pubsub_test.go
  • proxy/resp_compat_test.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

adapter と proxy の Redis コマンド応答を RESP2 の形式に合わせて変更しています。コマンドメタデータ、コマンド別の応答型、null array の扱いを更新し、これらを検証するテストを追加しています。

Changes: Redis RESP2 互換性

Layer / File(s) Summary
adapter のコマンド応答とメタデータ
adapter/redis.go, adapter/redis_server_cmds.go, adapter/redis_command_test.go, adapter/redis_resp_compat_test.go
PING は引数数に応じて PONG、メッセージ、またはエラーを返します。SELECT は DB index 0 以外をエラーにします。COMMAND INFO は10要素形式になり、COMMAND DOCS は group を含む形式になります。指定された未知コマンドは DOCS 応答から省略します。
adapter の読み取りと null array
adapter/redis_stream_cmds.go, adapter/redis_zset_cmds.go, adapter/redis_resp_compat_test.go
XREAD は BLOCK の有無を記録し、BLOCK 未指定時は1回だけ読み取ります。XREAD と BZPOPMIN の待機終了時や結果なしの場合は null array を返します。
proxy の管理コマンド処理
proxy/command.go, proxy/proxy.go, proxy/pubsub.go, proxy/resp_compat_test.go
proxy はコマンド名と引数を応答処理に渡します。PING と SELECT の検証を行い、HELLO 2 を上流へ転送します。COMMAND の応答は形式に応じて専用処理へ振り分けます。
proxy のコマンド別応答形式
proxy/command_info.go, proxy/proxy.go, proxy/proxy_test.go, proxy/pubsub.go, proxy/pubsub_test.go, proxy/resp_compat_test.go
proxy はコマンドに応じて単純文字列、bulk string、null array を書き分けます。COMMAND INFO と GETKEYSANDFLAGS の入れ子データを処理し、EXEC の要素もキュー内のコマンドに応じて書き込みます。

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Proxy
  participant RedisBackend
  participant RESP2Writer
  Client->>Proxy: HELLO 2 を送信
  Proxy->>RedisBackend: HELLO 2 を転送
  RedisBackend-->>Proxy: Redis 応答を返す
  Proxy->>RESP2Writer: 応答をコマンド別に書き込む
  RESP2Writer-->>Client: RESP2 応答を返す
Loading
Merge Risk: ⚪ Minimal · up to ab865

The change aligns RESP2 reply types in the proxy and adapter. No concrete merge-blocking risk was identified. The known parsed-proxy limits around module commands and Lua results are documented by the author.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 17.46% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 63 functions across 13 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed タイトルは、Redis adapter と proxy における RESP2 の応答型修正という、変更の主要目的を正確かつ簡潔に示しています。
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@bootjp
bootjp marked this pull request as ready for review October 13, 2026 15:48
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T17:53:46.797656Z b758260 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 96feff50a4

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread proxy/proxy.go
Comment thread adapter/redis_server_cmds.go

@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: fa84a87dda

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread proxy/proxy.go

@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

elastickv/proxy/proxy.go

Lines 699 to 700 in a55ef45

for _, item := range v {
writeRedisValue(w, item)

P2 Badge Retain script context when encoding nested replies

When EVAL, EVALSHA, or FCALL returns an array containing a status reply—for example, return {redis.status_reply('OK')}—the top-level value is a slice, so it bypasses the script-specific status check and this generic recursion emits the nested OK as a bulk string. Redis specifies that redis.status_reply produces a simple-string reply, and the previous recursive status handling preserved known tokens such as OK; carry the script-response context into nested arrays instead of dropping it at this fallback.

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread proxy/proxy.go Outdated
Comment thread proxy/proxy.go Outdated

@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: 59070afeb9

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread proxy/proxy.go Outdated
Comment thread proxy/proxy.go

@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: 26c8646952

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread proxy/proxy.go

@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: 6562be8d5c

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread proxy/proxy.go

@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: ab865072ad

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread proxy/proxy.go Outdated
@bootjp

bootjp commented Oct 13, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: b75826095b

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@bootjp
bootjp merged commit bbf4387 into main Oct 14, 2026
10 checks passed
@bootjp
bootjp deleted the feature/redis-resp2-replies branch October 14, 2026 11:35
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.

1 participant