Skip to content

fix: handle proto.Message and repeated fields in format_output_value#44

Open
danishashko wants to merge 1 commit intogoogleads:mainfrom
danishashko:fix/proto-serialization
Open

fix: handle proto.Message and repeated fields in format_output_value#44
danishashko wants to merge 1 commit intogoogleads:mainfrom
danishashko:fix/proto-serialization

Conversation

@danishashko
Copy link
Copy Markdown

Fixes #25

format_output_value() was only handling proto.Enum types. When a query returns fields like responsive_search_ad.headlines or responsive_search_ad.descriptions, the value is a RepeatedCompositeContainer (a list of proto messages), which isn't JSON-serializable as-is.

Changes:

  • Added handling for proto.Message values using proto.Message.to_dict()
  • Added recursive handling for list and tuple values so nested repeated fields are also serialized correctly
  • Existing behavior for proto.Enum and plain scalars is unchanged

This lets the search tool handle RSA headlines/descriptions and other repeated composite fields without crashing.

@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 1, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@Raibaz
Copy link
Copy Markdown
Collaborator

Raibaz commented Apr 2, 2026

Thanks for looking into this!

Would you be able to provide test coverage along with this change? See my comments to #26

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.

Bug: search tool fails to serialize RepeatedCompositeContainer fields (e.g. RSA headlines)

2 participants