Skip to content

#442: Omit GraphQL after argument when cursor is nil#444

Merged
yegor256 merged 2 commits into
zerocracy:masterfrom
bibonix:fix/442-omit-after-when-cursor-nil
May 1, 2026
Merged

#442: Omit GraphQL after argument when cursor is nil#444
yegor256 merged 2 commits into
zerocracy:masterfrom
bibonix:fix/442-omit-after-when-cursor-nil

Conversation

@bibonix

@bibonix bibonix commented May 1, 2026

Copy link
Copy Markdown
Contributor

@yegor256 this PR fixes #442.

The bug. Both pull_requests_with_reviews (line 294) and pull_request_reviews (line 356) in lib/fbe/github_graph.rb interpolated the cursor value directly into the GraphQL query as after: "#{cursor}". When the caller passed cursor: nil (for the first page), Ruby produced after: "" — an empty string, which is not a valid opaque cursor and is rejected/misinterpreted by the GitHub GraphQL API.

The fix. I mirrored the pattern already used correctly in total_commits_pushed (line 405): build an after = "after: "#{cursor}", " unless cursor.nil? snippet and interpolate it into the query. When cursor is nil, after is nil and the after: argument is omitted from the query entirely. When cursor is a real cursor, the argument is rendered as before. This required a one-line change inside each of the two methods.

Tests. I added two tests in test/fbe/test_github_graph.rb that capture the GraphQL query string sent through Fbe::Graph#query and assert it does not contain after: "" when cursor is nil. Both tests fail on master and pass with this change. The full test suite (bundle exec rake test) and rubocop both pass locally and in CI.

Ready for merge.

bibonix added 2 commits May 1, 2026 12:32
…ssert it does not include 'after: ""' when cursor is nil
…views and pull_request_reviews when cursor is nil
@yegor256 yegor256 merged commit 9ab8cf3 into zerocracy:master May 1, 2026
10 checks passed
@0crat

0crat commented May 1, 2026

Copy link
Copy Markdown

@bibonix Hey! Nice work on that contribution – you just scored the full +24 points! 🎉 Your code hit the sweet spot with good size and solid review feedback, which is exactly how our bonus system rewards quality work. Keep them coming and you'll see those points add up fast! Your running score is +180, so don't forget to check your Zerocracy account for the latest updates.

VasilevNStas added a commit to VasilevNStas/fbe that referenced this pull request Jun 3, 2026
…sibling methods

total_releases_published always interpolated after: "#{cursor}"
in the GraphQL query, even when cursor was nil. This produced
after: "" on the first page, which is an invalid pagination
argument — the same bug fixed for pull_requests_with_reviews
and pull_request_reviews in PR zerocracy#444.

Applied the same pattern used by total_commits_pushed (line 410),
pull_requests_with_reviews (line 293), and pull_request_reviews
(line 356): conditionally build the after argument only when
cursor is not nil.
yegor256 pushed a commit that referenced this pull request Jun 13, 2026
* fix: make total_releases_published conditional after cursor, same as sibling methods

total_releases_published always interpolated after: "#{cursor}"
in the GraphQL query, even when cursor was nil. This produced
after: "" on the first page, which is an invalid pagination
argument — the same bug fixed for pull_requests_with_reviews
and pull_request_reviews in PR #444.

Applied the same pattern used by total_commits_pushed (line 410),
pull_requests_with_reviews (line 293), and pull_request_reviews
(line 356): conditionally build the after argument only when
cursor is not nil.

* test: add regression test for nil cursor in total_releases_published
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pull_requests_with_reviews sends after: "" instead of omitting after when cursor is nil

3 participants