Skip to content

Add DoRaw and DoRawWriteTo for raw RESP protocol access#3713

Merged
ndyakov merged 6 commits into
masterfrom
add-raw-response-command
Mar 23, 2026
Merged

Add DoRaw and DoRawWriteTo for raw RESP protocol access#3713
ndyakov merged 6 commits into
masterfrom
add-raw-response-command

Conversation

@ofekshenawa

@ofekshenawa ofekshenawa commented Feb 18, 2026

Copy link
Copy Markdown
Collaborator

Adds two new methods for accessing raw RESP protocol bytes:

  • DoRaw(ctx, args...) - Returns raw RESP bytes, useful for custom parsing
  • DoRawWriteTo(ctx, writer, args...) - Streams RESP bytes directly to an io.Writer without intermediate allocations

Add RawCmd and RawWriteToCmd types that return raw RESP protocol bytes
without parsing, allowing users to implement custom deserialization.

Closes #3698


Note

Medium Risk
Adds new raw-reply execution paths and modifies core retry behavior (single and pipelined, including cluster/ring) to honor a new NoRetry contract, which could affect failure handling if misapplied.

Overview
Adds DoRaw and DoRawWriteTo APIs plus new command types (RawCmd, RawWriteToCmd) to let callers receive raw RESP replies as bytes or stream them directly to an io.Writer.

Implements raw-reply reading in proto.Reader (buffered and streaming, including nested types and RESP3 attributes) and introduces a Cmder.NoRetry() flag; retry loops for standalone commands and pipelines (including cluster/ring) now skip retries when any command is marked non-retryable to avoid partial-write corruption. Tests are expanded to validate raw outputs across common reply types and the new no-retry behavior.

Written by Cursor Bugbot for commit 4150e19. This will update automatically on new commits. Configure here.

@ofekshenawa ofekshenawa requested a review from ndyakov February 18, 2026 15:31
@ofekshenawa ofekshenawa marked this pull request as ready for review February 19, 2026 13:36

@ndyakov ndyakov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Left some comments, let's discuss and test if we can directly use io.Copy when we use a writer.

Comment thread command_test.go
Comment thread internal/proto/reader.go
@jit-ci

jit-ci Bot commented Feb 26, 2026

Copy link
Copy Markdown

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

Comment thread command.go
Comment thread internal/proto/reader.go
Comment thread internal/proto/reader.go
@ofekshenawa ofekshenawa force-pushed the add-raw-response-command branch from a02cc5b to f531cad Compare March 11, 2026 14:49
ndyakov
ndyakov previously approved these changes Mar 12, 2026
Comment thread internal/proto/reader.go
Comment thread redis.go
Comment thread redis.go
@ndyakov

ndyakov commented Mar 18, 2026

Copy link
Copy Markdown
Member

@fdimuccio please take a look if this covers your usecase. I am willing to proceed with this PR and merge it.

@fdimuccio

Copy link
Copy Markdown

@ndyakov it looks perfect, DoRawWriteTo is exactly what I was looking for. Thank you!

@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 and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread command.go
@ofekshenawa ofekshenawa requested a review from ndyakov March 23, 2026 09:28

@ndyakov ndyakov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you @ofekshenawa!

@ndyakov ndyakov merged commit 5b69d1a into master Mar 23, 2026
53 of 57 checks passed
@ndyakov ndyakov deleted the add-raw-response-command branch March 23, 2026 15:36
ndyakov pushed a commit to olde-ducke/go-redis that referenced this pull request Mar 23, 2026
…redis#3713)

* Add DoRaw and DoRawWriteTo for raw RESP protocol access

* fix augment comments

* Pipeline retry fix

* Fix Missing NoRetry check in cluster and ring retry loops
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: allow custom commands via Cmder interface

3 participants