Skip to content

fix: Stop checking returned page size against requested page size.#872

Merged
amanda-tarafa merged 1 commit into
googleapis:mainfrom
amanda-tarafa:pagination-check
Mar 3, 2026
Merged

fix: Stop checking returned page size against requested page size.#872
amanda-tarafa merged 1 commit into
googleapis:mainfrom
amanda-tarafa:pagination-check

Conversation

@amanda-tarafa
Copy link
Copy Markdown
Collaborator

This relies on the API to do the right thing and avoids breaking Compute's Aggregate pagination methods. See b/481247371.

@amanda-tarafa amanda-tarafa requested a review from a team as a code owner March 2, 2026 23:32
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue where the client-side pagination logic was overly strict, causing breakage in Google Compute's Aggregate pagination methods. The change removes the client's enforcement of returned page size matching the requested page size, instead relying on the API to handle pagination correctly. This ensures compatibility with APIs that may return varying page sizes under specific conditions, such as aggregate results, and updates the public documentation to reflect this behavior.

Highlights

  • Removed Strict Page Size Validation: The client-side code no longer throws a NotSupportedException if the number of items returned by the server exceeds the requested page size. This change is applied across both gRPC and REST pagination implementations.
  • Updated Pagination Documentation: The XML documentation for ReadPage and ReadPageAsync methods has been clarified to explain that the returned page size is not strictly guaranteed to match the requested size, especially for aggregate pagination scenarios where a single resource might contain multiple items.
  • Adjusted Test Expectations: Unit tests that previously expected a NotSupportedException when a page size of 0 was requested now assert that a non-zero count of items is returned, aligning with the new relaxed validation logic.
Changelog
  • Google.Api.Gax.Grpc.Tests/PageStreamingTest.cs
    • Modified BrokenServerFixedSizePaged and BrokenServerFixedSizePagedAsync tests to assert Assert.NotEqual(0, paged.Count()) instead of Assert.Throws<NotSupportedException>.
  • Google.Api.Gax.Grpc/GrpcPagedAsyncEnumerable.cs
    • Removed the NotSupportedException check for items.Count > pageSize within GetCompletePageAsync.
    • Removed unused System and System.Linq usings.
  • Google.Api.Gax.Grpc/GrpcPagedEnumerable.cs
    • Removed the NotSupportedException check for items.Count > pageSize within ReadPage.
    • Removed unused System and System.Collections usings.
  • Google.Api.Gax.Rest.Tests/PageStreamingTest.cs
    • Modified BrokenServerFixedSizePaged and BrokenServerFixedSizePagedAsync tests to assert Assert.NotEqual(0, paged.Count()) instead of Assert.Throws<NotSupportedException>.
  • Google.Api.Gax.Rest/RestPagedAsyncEnumerable.cs
    • Removed the NotSupportedException check for items.Count > pageSize within GetCompletePageAsync.
    • Removed unused System.Linq using.
  • Google.Api.Gax.Rest/RestPagedEnumerable.cs
    • Removed the NotSupportedException check for items.Count > pageSize within ReadPage.
    • Removed unused System.Collections using.
  • Google.Api.Gax/PagedAsyncEnumerable.cs
    • Updated XML documentation for ReadPageAsync to detail scenarios where returned page size might differ from requested.
  • Google.Api.Gax/PagedEnumerable.cs
    • Updated XML documentation for ReadPage to detail scenarios where returned page size might differ from requested.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the strict check on the returned page size against the requested page size in the pagination logic. This change is applied consistently across gRPC and REST implementations, for both synchronous and asynchronous methods. The tests are updated to reflect this change, and the documentation is updated to clarify the new behavior. The changes are reasonable and well-implemented. I've found a couple of minor typos in the updated XML documentation comments that should be corrected for clarity.

Comment thread Google.Api.Gax/PagedAsyncEnumerable.cs Outdated
Comment thread Google.Api.Gax/PagedEnumerable.cs Outdated
This relies on the API to do the right thing and avoids breaking Compute's Aggregate pagination methods. See b/481247371.
var request = new PageStreamingRequest { PageSize = 0 };
var paged = server.PagedSync(null, null, request);
Assert.Throws<NotSupportedException>(() => paged.ReadPage(1));
Assert.NotEqual(0, paged.Count());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This highlights something we should add to the internal clarification doc: there should be at least one entry across all the keys in any given response page. I'll do that now.

@amanda-tarafa amanda-tarafa merged commit c388c56 into googleapis:main Mar 3, 2026
5 checks passed
@amanda-tarafa amanda-tarafa deleted the pagination-check branch March 3, 2026 17:59
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.

3 participants