Ruby: max_retries: 0 made zero requests on an ungoverned GET (#532)
Closes #532.
The defect
A Ruby client configured with max_retries: 0 made zero HTTP requests on any ungoverned GET and raised Basecamp::ApiError("Request failed after 0 attempts").
ruby/lib/basecamp/http.rb floored the cap at one attempt on the governed branch but used the raw @config.max_retries on the ungoverned branch of the same expression, so break if attempt > max_attempts fired before the first request.
Whether a request reached the wire depended on whether the operation carried a declared retry block — same client, same method, same config.
The fix
Floor the cap on every path. The retry_on branch and the ungoverned branch only ever resolved to caller_cap, so the three-branch expression collapses to a ternary. retry_on stays load-bearing for the retryable-status set (retry_eligible?, http.rb:459/:485) — only its redundant budget arm went away.
Ruby now matches Kotlin's config.maxRetries.coerceAtLeast(1).
Red proof, against the un-fixed code
The tests assert the request count, not the error class — the un-fixed path raises the same class from the same method, so only "did a request happen" separates fixed from broken.
Run options: -n /zero_max_retries/ --seed 12906
.E
1) Error:
HTTPGovernedRetryTest#test_ungoverned_get_with_zero_max_retries_still_makes_one_request:
Basecamp::ApiError: Request failed after 0 attempts
lib/basecamp/http.rb:481:in 'Basecamp::Http#request_with_retry'
lib/basecamp/http.rb:383:in 'Basecamp::Http#request'
lib/basecamp/http.rb:63:in 'Basecamp::Http#get'
2 runs, 2 assertions, 0 failures, 1 errors, 0 skips
REAL_EXIT=1
The governed test passes against un-fixed code (.) — that is the point of the pair. It pins the two branches together so they cannot drift apart again.
After the fix: 2 runs, 4 assertions, 0 failures, 0 errors.
Docs corrected
Both places that documented the bug as behavior:
SPEC.md§2 rule 4 — the Ruby bullet described the zero-request outcome as a known divergence. Rewritten; the summary line drops from three distinct outcomes across four implementations to two, since Ruby's outcome now collapses into Kotlin's.ruby/README.md:447— stated "max_retries: 0sends zero requests". That would have shipped as a false claim.
Verification
make check-readme-env-vars check-retry-metadata-parity rb-check — real exit code written to a marker file and grepped back:
1362 runs, 30397 assertions, 0 failures, 0 errors, 0 skips
Line coverage: 2049 / 2130 (96.19%) Branch coverage: 667 / 784 (85.07%)
153 files inspected, no offenses detected
✓ Ruby consumes max + retry_on — http.rb retries governed GETs with min(caller cap, maxAttempts)
MARKER_GATES_REAL_EXIT=0
247 operations unchanged. Not breaking: this only turns a no-op-and-raise into a request.
Summary by cubic
Fixes Ruby GET retry logic where max_retries: 0 sent zero requests on ungoverned GETs by flooring attempts to at least one across all paths. Behavior now matches Kotlin (always at least one attempt).
- Bug Fixes
- Floor attempt cap to
max(1, config.max_retries)on every GET path; governed operations still clamp to their declared ceiling. - Collapse branching to a ternary;
retry_onstill gates which statuses retry. - Add tests asserting one request for governed and ungoverned GETs when
max_retries: 0. - Update docs: clarify universal attempt floor; governed vs ungoverned status gates (governed GETs don’t retry 500); download flow behavior; and that Ruby consumes
maxandretry_onon governed GETs (SPEC.md§§2, 7, 14;ruby/README.md;scripts/check-retry-metadata-parity.py; fix download test comment). - Non-breaking: turns a no-op-and-raise into a single request.
- Floor attempt cap to