Skip to content

DOC-7226 Fix the Ruby job-queue and streaming demos on Ruby 4.0 and the index-readiness snippet - #4386

Merged
andy-stark-redis merged 1 commit into
mainfrom
DOC-7226-ruby-python-bugs
Oct 30, 2026
Merged

andy-stark-redis merged 1 commit into
mainfrom
DOC-7226-ruby-python-bugs

Conversation

@andy-stark-redis

@andy-stark-redis andy-stark-redis commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Seventh slice of DOC-7226: three small bugs found while verifying the earlier PRs. None of them is a deprecation; each is a snippet or demo that doesn't run.

Ruby job-queue and streaming demos on Ruby 4.0

  • Both parsed form bodies with CGI.parse, which Ruby 4.0 removed, so every form POST returned 500. They now use URI.decode_www_form, as the feature-store and recommendation-engine Ruby demos already do, returning a hash of arrays that reads a missing key as an empty array (what CGI.parse did). require 'cgi' becomes require 'uri'; CGI was used nowhere else in those files.
  • The streaming demo had a second bug that the first one hid. send_json(res, payload, status: 200) takes keyword arguments, and its seven success responses passed the payload as a braceless hash (send_json(res, 'produced' => n, ...)). Ruby 4.0 reads that as keywords and fails with wrong number of arguments (given 1, expected 2). The error responses were already in braces; the success ones now are too. (Ruby 2.6 accepts the old form; I couldn't test Ruby 3.x.)
  • Checked the other Ruby demos (cache-aside, leaderboard, session-store, recommendation-engine, feature-store) for the same braceless pattern: none.

check_index_readiness on the index management page

  • It imported re instead of redis, and its return statement stopped at expected_d.
  • Fixing those still left it broken on current redis-py, where execute_command('FT.INFO') returns a dict (so info.index(...) raises). It now reads r.ft(index_name).info()['num_docs'].

Verification

  • Ruby 4.0.6, no shim: the job-queue demo completed 8 of 8 jobs. Every streaming endpoint (/produce, /add-worker, /remove-worker, /state, /replay, /crash, /autoclaim, /trim, /reset) returned 200, including an empty-body POST.
  • The Python snippet was extracted from the published page text and run against a real index (5 documents) on redis-py 8.1.0 and 5.2.1: "still populating" at a 100,000 threshold and "fully populated" at 3, on both.
  • This PR touches job-queue/ruby/demo_server.rb, which the open DOC-7226 Move the job-queue Jedis, PHP, redis-py and Ruby ports to BLMOVE #4384 also edits (different lines); git merge-tree shows no conflict.

🤖 Generated with Claude Code


Note

Low Risk
Documentation and local demo-server fixes only; no production services or security-sensitive paths.

Overview
Restores runnable docs and demos that broke on current Ruby and redis-py, without changing product behavior.

Index management best practices — The check_index_readiness Python example now imports redis, completes the expected_docs comparison, and reads document count via r.ft(index_name).info()['num_docs'] instead of raw FT.INFO list parsing.

Ruby job-queue and streaming demo servers (Ruby 4.0) — Form POST bodies no longer use removed stdlib CGI.parse; both demos parse application/x-www-form-urlencoded with URI.decode_www_form and a hash-of-arrays helper (missing keys → empty arrays). The streaming demo also wraps success send_json payloads in explicit { ... } hashes so Ruby 4 does not treat hash rockets as keyword arguments to send_json(..., status: 200).

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

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

DOC-7226

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Redis Memory

Found 7 related items from repository history (2 new this commit):

Memory updated at 1780145

@github-actions

Copy link
Copy Markdown
Contributor

…he index-readiness snippet

The job-queue and streaming Ruby demos parsed form bodies with CGI.parse, which Ruby 4.0 removed, so
every form POST returned 500. They now use URI.decode_www_form, the way the feature-store and
recommendation-engine Ruby demos already do, and return a hash of arrays that reads a missing key as
an empty array, as CGI.parse did. The streaming demo had a second bug that CGI hid: send_json takes
keyword arguments (status:), and its success responses passed the payload as a braceless hash
(send_json(res, 'produced' => n)), which Ruby 4.0 reads as keywords, so the call failed with a
wrong-number-of-arguments error. Its error responses were already wrapped in braces; the seven success
calls now are too.

The check_index_readiness snippet on the index management page imported re instead of redis and ended
its return at expected_d. Fixing those still left it broken on current redis-py, where execute_command
returns FT.INFO as a dict under the new default protocol and info.index() raises, so it now reads
r.ft(index_name).info()['num_docs'], which works on redis-py 5.2.1 and 8.1.0 under RESP2 and RESP3.

Verification on Ruby 4.0.6 with no shim: the job-queue demo completed 8 of 8 jobs, and every streaming
endpoint (produce, add and remove worker, state, replay, crash, autoclaim, trim, reset) returned 200.
The page snippet was extracted from the published text and run against a real index on both redis-py
versions.

Learned: on Ruby 4.0 a braceless hash with string keys passed to a method that declares keyword arguments is read as keywords, so send_json(res, 'k' => v) fails with an arity error whenever the helper has status:, and wrapping the payload in braces fixes it (Ruby 2.6 accepts it; Ruby 3.x was not tested)
Learned: redis-py 8 returns FT.INFO from execute_command as a dict, so code that indexes the raw reply by position breaks; use r.ft(name).info()
Gaps: the Ruby port was tested on main without the BLMOVE change from the open job-queue PR, which merges cleanly with this one
Ticket: DOC-7226
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@andy-stark-redis
andy-stark-redis force-pushed the DOC-7226-ruby-python-bugs branch from ad469a0 to 1780145 Compare October 30, 2026 11:07
@andy-stark-redis
andy-stark-redis requested a review from a team October 30, 2026 12:59
@andy-stark-redis andy-stark-redis self-assigned this Oct 30, 2026
@andy-stark-redis andy-stark-redis added the clients Client library docs label Oct 30, 2026

@dwdougherty dwdougherty 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.

@andy-stark-redis
andy-stark-redis merged commit b61d3c8 into main Oct 30, 2026
103 checks passed
@andy-stark-redis
andy-stark-redis deleted the DOC-7226-ruby-python-bugs branch October 30, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clients Client library docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants