Repository navigation
fix(csharp,unity,php,ruby): keep paginating on the result length when numPages is missing or null - #187
Draft
AshGodfrey wants to merge 1 commit into
Draft
fix(csharp,unity,php,ruby): keep paginating on the result length when numPages is missing or null#187AshGodfrey wants to merge 1 commit into
AshGodfrey wants to merge 1 commit into
Conversation
AshGodfrey
marked this pull request as draft
November 3, 2026 13:23
There was a problem hiding this comment.
1 issue found across 20 files
Confidence score: 4/5
PaginationShould.cscan pass even if pagination makes an unwanted fourth HTTP request, so the test may miss a regression. UsePaginationRecorderClientand assert exactly three requests.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="templates/templates/csharp/tests/primary/PaginationShould.cs">
<violation number="1" location="templates/templates/csharp/tests/primary/PaginationShould.cs:214">
P2: This regression test does not verify that pagination avoids the fourth HTTP request: `Assert.Null(nullRes)` can pass after an unwanted page-4 fetch. Use `PaginationRecorderClient` and assert that exactly three requests were recorded.</violation>
</file>
Shadow auto-approve: would not auto-approve because issues were found.
View guided diff | Turn on auto-fix | Re-trigger cubic
| public async Task PaginationLimitOffsetPageNumPagesMissing() | ||
| { | ||
| CommonHelpers.RecordTest("pagination-limit-offset-page-num-pages-missing"); | ||
| var sdk = new SDK(serverUrl: Helpers.HttpBinUrl); |
There was a problem hiding this comment.
P2: This regression test does not verify that pagination avoids the fourth HTTP request: Assert.Null(nullRes) can pass after an unwanted page-4 fetch. Use PaginationRecorderClient and assert that exactly three requests were recorded.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At templates/templates/csharp/tests/primary/PaginationShould.cs, line 214:
<comment>This regression test does not verify that pagination avoids the fourth HTTP request: `Assert.Null(nullRes)` can pass after an unwanted page-4 fetch. Use `PaginationRecorderClient` and assert that exactly three requests were recorded.</comment>
<file context>
@@ -207,6 +207,39 @@ public async Task PaginationLimitOffsetPageBodyNullable()
+ public async Task PaginationLimitOffsetPageNumPagesMissing()
+ {
+ CommonHelpers.RecordTest("pagination-limit-offset-page-num-pages-missing");
+ var sdk = new SDK(serverUrl: Helpers.HttpBinUrl);
+
+ // the test service omits numPages on the first page and returns null on
</file context>
… numPages is missing or null When an offsetLimit operation declares both a numPages and a results output, a response that omits numPages or sends it as null no longer ends pagination. The C#, Unity, PHP and Ruby paginators now stop only on a numeric numPages <= page and otherwise fall back to the results-length check, matching Go, TypeScript and Python. Java already paginates on the result length through ResultsPageTracker, so it only gains the runtime test.
AshGodfrey
force-pushed
the
ash/pagination-numpages-fallback-remaining-targets
branch
from
November 16, 2026 11:10
846f471 to
5fbcefe
Compare
Generator Snapshot Testing
Snapshot results: https://github.com/speakeasy-api/openapi-generation-snapshots/issues/170#issuecomment-6914913004 Snapshot results are summarized above. Additional run context is linked for maintainers with access. |
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.
Summary
When an
offsetLimitpagination operation declares both anumPagesand aresultsoutput, the C#, Unity, PHP and Ruby SDKs ended pagination as soon as a response omittednumPagesor sent it asnull: C# and Unity returnednullfromNext(), Ruby raisedNoMethodErrorcomparingnil <= page, and PHP compared a missing path result against the page. They now stop only whennumPagesis numeric and<= page; otherwise they fall through to the results-length check (an empty or short page ends pagination), matching the Go, TypeScript and Python behaviour (fixed separately).Java needed no template change: with a
resultsoutput the generated paginator already usesResultsPageTracker, which advances on the page length. This PR adds the runtime test for Java and removes its skip; the top-level Java lambda template is not rendered by the generator and is left untouched.Behaviour change
A server that omits
numPagesand clamps out-of-range page numbers (keeps returning a full last page) previously stopped silently after the first page in these SDKs; it will now keep requesting pages. Such a server must return an empty or short page past the end, or statenumPages.Tests
tests/specs/fragments/uber/pagination-num-pages-missing.yaml(paginationLimitOffsetPageNumPagesMissing) and api-test-service handler/pagination/limitoffset/page/num_pages_missing: page 1 omitsnumPages, page 2 sendsnull, page 3 sends3; limit 7, 20 items.numPageswhere the model distinguishes them (C#OptionalNullable, JavaJsonNullable), the exact result arrays[0..6],[7..13],[14..19], and that no fourth page is fetched.Next()returnsnullafter page 1; Ruby:undefined method '<=' for nil) and pass with it; Java passes. PHP relies on CI; Unity has no test runner.pagination-limit-offset-page-num-pages-missingin their skip lists until their own fix lands.Summary by cubic
Fixes premature pagination termination in the C#, Unity, PHP, and Ruby SDKs when an offsetLimit operation declares both
numPagesandresultsoutputs.Previously, a response that omitted
numPagesor sent it asnullended pagination after the first page. These SDKs now only stop whennumPagesis numeric and<= page; otherwise, they fall back to the results-length check, matching Go, TypeScript, and Python. Java already paginated correctly throughResultsPageTracker, so it only gains the runtime test.Behavior change
numPagesand keeps returning a full last page will now keep getting requested until it returns an empty or short page or statesnumPages.Tests
numPages, page 2 sendsnull, page 3 sends3.Written for commit 5fbcefe. Summary will update on new commits.