Skip to content

fix: use proto default values in generated a2a_types.ts#303

Merged
guglielmo-san merged 8 commits into
a2aproject:mainfrom
guglielmo-san:guglielmoc/update_a2a_types
Jan 20, 2026
Merged

fix: use proto default values in generated a2a_types.ts#303
guglielmo-san merged 8 commits into
a2aproject:mainfrom
guglielmo-san:guglielmoc/update_a2a_types

Conversation

@guglielmo-san

@guglielmo-san guglielmo-san commented Jan 16, 2026

Copy link
Copy Markdown
Member

Description

This PR standardizes the handling of optional fields in the generated a2a_types and converters. It aligns the codebase with Protobuf standards by replacing undefined checks with empty string checks for missing string values.

Key Changes

  • Generated Types (a2a_types.ts):

    • Removed the optionality from generated string fields.
    • Updated fromJSON and toJSON methods to validate against empty strings ("") instead of undefined for missing values.
  • Converters:

    • ToProto: Updated to convert undefined domain fields into empty strings, ensuring compliance with the new non-optional proto types.
    • FromProto: Updated to convert empty strings from the proto layer back into undefined, preserving the existing undefined semantics for the internal domain model.

Motivation
These changes ensure consistency with the Protobuf specification, where missing strings must default to the empty string rather than undefined.

@github-actions

github-actions Bot commented Jan 16, 2026

Copy link
Copy Markdown

🧪 Code Coverage

⬇️ Download Full Report

No coverage changes.

Generated by coverage-comment.yml

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @guglielmo-san, 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 refines the handling of optional fields within the a2a_types and their conversion logic to and from Protobuf messages. The primary goal is to achieve consistency with Protobuf specifications, where missing string values are typically represented as empty strings. This change ensures a more robust and predictable data flow between the internal domain model and the Protobuf layer, supported by an updated Protobuf generation toolchain.

Highlights

  • Protobuf Type Standardization: Optional string and boolean fields in generated a2a_types.ts are now non-optional, defaulting to empty strings or false respectively, aligning with Protobuf's handling of missing scalar values.
  • Conversion Logic Updates: FromProto converter now explicitly converts empty strings received from the Protobuf layer back to undefined for the internal domain model, preserving existing semantics. ToProto converter now converts undefined values from the internal domain model to empty strings or false when creating Protobuf messages.
  • Protobuf Tooling Integration: New buf configuration files (buf.gen.yaml, buf.lock, buf.yaml) have been added, indicating a shift or update in the Protobuf generation workflow.
  • ts-proto Version Upgrade: The protoc-gen-ts_proto tool has been upgraded to v2.11.0, which likely necessitated some of the type and conversion changes.
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.

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

Copy link
Copy Markdown
Contributor

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 effectively standardizes the handling of optional fields in the generated a2a_types and converters, aligning the codebase with Protobuf standards. The changes are consistent and well-executed.

  • The generated types in a2a_types.ts now correctly use default values for scalar types (e.g., '' for strings, 0 for numbers, false for booleans) instead of undefined, and the fromJSON/toJSON methods have been updated accordingly.
  • The ToProto converter now correctly maps undefined values in the domain model to empty strings for the Protobuf layer.
  • The FromProto converter correctly maps empty strings from the Protobuf layer back to undefined for the internal domain model, maintaining existing semantics.
  • The addition of buf configuration files is a great improvement for managing Protobuf definitions.

The changes are thorough and improve the consistency and correctness of the type conversions. I have no further comments.

@guglielmo-san guglielmo-san marked this pull request as ready for review January 16, 2026 16:09
@guglielmo-san guglielmo-san requested a review from a team as a code owner January 16, 2026 16:09
@guglielmo-san guglielmo-san requested a review from ishymko January 19, 2026 13:41
Comment thread src/types/converters/from_proto.ts Outdated
Comment thread src/types/pb/google/protobuf/descriptor.ts Outdated
Comment thread src/types/buf.gen.yaml
@guglielmo-san guglielmo-san requested a review from ishymko January 19, 2026 15:14
Comment thread src/types/README.md Outdated
Comment thread src/types/converters/to_proto.ts
@ishymko ishymko changed the title fix: Update a2a_types format and conversion logic refactor: update a2a_types format and conversion logic Jan 19, 2026
@ishymko ishymko changed the title refactor: update a2a_types format and conversion logic fix: use proto default values in generated a2a_types.ts Jan 19, 2026
@guglielmo-san guglielmo-san requested a review from ishymko January 19, 2026 18:08
@guglielmo-san guglielmo-san merged commit 0215d42 into a2aproject:main Jan 20, 2026
14 checks passed
@guglielmo-san guglielmo-san deleted the guglielmoc/update_a2a_types branch January 20, 2026 08:52
ishymko pushed a commit that referenced this pull request Jan 21, 2026
🤖 I have created a release *beep* *boop*
---


## [0.3.9](v0.3.8...v0.3.9)
(2026-01-21)


### Features

* implement gRPC client
([#299](#299))
([dbdb96e](dbdb96e))
* implement gRPC server
([#279](#279))
([bd4caa2](bd4caa2))


### Bug Fixes

* use proto default values in generated a2a_types.ts
([#303](#303))
([0215d42](0215d42))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

2 participants