Skip to content

Handle a missing total_results in all_results - #80

Merged
Sija merged 1 commit into
masterfrom
fix/all-results-missing-total
Nov 21, 2026
Merged

Sija merged 1 commit into
masterfrom
fix/all-results-missing-total

Conversation

@Sija

@Sija Sija commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

 all_results
   loop pages
-    break if next_offset > total_results           # total_results may be nil
+    total = results.total_results
+    break if total ? next_offset > total : page.size < max-results

When the response has no totalResults, the stop check compared an Integer with nil and raised. Without a known total, paging now stops at the first page shorter than requested.

Evidence

  • Before:
    total_results = nil
    all_results(profile)  # ArgumentError: comparison of Integer with nil failed
    127 tests, 223 assertions, 0 failures, 1 errors
    
    After: 127 tests, 225 assertions, 0 failures, 0 errors (one request, one page returned)

Merge Danger

Door: two-way

Blast Radius: small

Relies on the API returning full pages until the last one when the total is unknown.

🤖 Generated with Claude Code

Comment thread lib/garb/model.rb

break if limit && results.size >= limit
break if next_offset > results.total_results
# without a known total, a short page means there is nothing more to fetch

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.

Metrics/LineLength: Line is too long. [82/80]

@results.total_results = nil
results = @test_model.all_results(@profile)
assert_equal @results.to_a, results.to_a
assert_received(Request::Data, :new) { |e| e.once }

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.

Style/SymbolProc: Pass &:once as an argument to assert_received instead of a block.

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • 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

@Sija Sija added the bug label Nov 21, 2026
When the response has no `totalResults`, `next_offset > results.total_results` raised `ArgumentError` (comparison of `Integer` with `nil`). Without a known total, stop once a page comes back shorter than requested.

Assisted-by: Claude:claude-opus-5-5
@Sija
Sija force-pushed the fix/all-results-missing-total branch from 5720248 to 9e0a934 Compare November 21, 2026 22:15
@Sija
Sija merged commit 9c96ce1 into master Nov 21, 2026
5 of 6 checks passed
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.

2 participants