Skip to content

Conversation

@google-labs-jules
Copy link

@google-labs-jules google-labs-jules bot commented Jan 23, 2026

Switching from struct_pb2.ListValue to collections.abc.Sequence (and Struct to Mapping) to fix test failures identified in #2534 and make the generated tests more resilient.

Why the test is failing

When we compare gRPC and HTTP responses:

  • gRPC typically returns the actual Protobuf Message object (e.g., an instance of struct_pb2.ListValue).
  • HTTP/REST (using libraries like requests or aiohttp) usually returns native Python types (e.g., a standard list or dict) after the JSON body is decoded.

Because a standard Python list is not an instance of struct_pb2.ListValue, your check isinstance(i, struct_pb2.ListValue) returns False for the HTTP response, even if the data inside is identical.

The "Primitive" Types (ABCs)

The Protocol Buffer implementation for Python registers Struct and ListValue with Python’s Abstract Base Classes (ABCs). This means they are designed to "masquerade" as native collections.

Protobuf Type Primary ABC Secondary ABC
Struct collections.abc.Mapping collections.abc.MutableMapping
ListValue collections.abc.Sequence collections.abc.MutableSequence
Value (None) (A wrapper message, not a container)

Updated Check

from collections.abc import Sequence, Mapping

# This will return True for BOTH a struct_pb2.ListValue AND a native Python list []
assert all(isinstance(i, Sequence) for i in responses)

# Using Mapping if we are checking a Struct/dict
assert isinstance(my_struct_or_dict, Mapping)

This aligns the tests with proto-plus behavior regarding Well-Known Types.


PR created automatically by Jules for task 9413892356993396464 started by @chalmerlowe

Relax assertion checks in generated pager tests to allow `Sequence` for `struct_pb2.ListValue` and `Mapping` for `struct_pb2.Struct`, as `proto-plus` converts these WKTs to native Python types. Also handles `struct_pb2.Value` mapping to `Any`.

This fixes an `AssertionError` where tests expected `struct_pb2.ListValue` instances but received list-like objects (e.g. `RepeatedComposite` or `list`).
@google-labs-jules
Copy link
Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@product-auto-label product-auto-label bot added the size: s Pull request size is small. label Jan 23, 2026
@chalmerlowe chalmerlowe marked this pull request as ready for review January 23, 2026 12:38
@chalmerlowe chalmerlowe requested a review from a team as a code owner January 23, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: s Pull request size is small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant