Repository navigation
DOC-7226 Fix the Ruby job-queue and streaming demos on Ruby 4.0 and the index-readiness snippet - #4386
Merged
Conversation
Contributor
Contributor
🧠 Redis MemoryFound 7 related items from repository history (2 new this commit):
Memory updated at 1780145 |
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
force-pushed
the
DOC-7226-ruby-python-bugs
branch
from
October 30, 2026 11:07
ad469a0 to
1780145
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
CGI.parse, which Ruby 4.0 removed, so every form POST returned 500. They now useURI.decode_www_form, as thefeature-storeandrecommendation-engineRuby demos already do, returning a hash of arrays that reads a missing key as an empty array (whatCGI.parsedid).require 'cgi'becomesrequire 'uri'; CGI was used nowhere else in those files.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 withwrong 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.)cache-aside,leaderboard,session-store,recommendation-engine,feature-store) for the same braceless pattern: none.check_index_readinesson the index management pagereinstead ofredis, and its return statement stopped atexpected_d.execute_command('FT.INFO')returns a dict (soinfo.index(...)raises). It now readsr.ft(index_name).info()['num_docs'].Verification
/produce,/add-worker,/remove-worker,/state,/replay,/crash,/autoclaim,/trim,/reset) returned 200, including an empty-body POST.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-treeshows 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_readinessPython example now importsredis, completes theexpected_docscomparison, and reads document count viar.ft(index_name).info()['num_docs']instead of rawFT.INFOlist parsing.Ruby job-queue and streaming demo servers (Ruby 4.0) — Form POST bodies no longer use removed stdlib
CGI.parse; both demos parseapplication/x-www-form-urlencodedwithURI.decode_www_formand a hash-of-arrays helper (missing keys → empty arrays). The streaming demo also wraps successsend_jsonpayloads in explicit{ ... }hashes so Ruby 4 does not treat hash rockets as keyword arguments tosend_json(..., status: 200).Reviewed by Cursor Bugbot for commit 1780145. Bugbot is set up for automated code reviews on this repo. Configure here.