Skip to content

fix(compat/v0_3/translate): add null and undefined checks to array and string fields - #618

Merged
JakubWorek merged 2 commits into
mainfrom
jakubworek/fix-issue-616
Aug 5, 2026
Merged

JakubWorek merged 2 commits into
mainfrom
jakubworek/fix-issue-616

Conversation

@JakubWorek

@JakubWorek JakubWorek commented Aug 3, 2026 •

Copy link
Copy Markdown
Member

Description

The v0.3 compat translators dereferenced V1/legacy array/object fields without any guard, so a partial object crashed with TypeError: Cannot read properties of undefined (reading 'length') inside nonEmptyArray.

Two-part fix:

  1. Optional v0.3 fields (referenceTaskIds, extensions, history, artifacts, signatures, securitySchemes, securityRequirements, examples/inputModes/outputModes, acceptedOutputModes) — silently coerced to []/undefined when missing. nonEmptyArray/nonEmptyString helpers now accept T[] | undefined | null / string | undefined | null.
  2. Required v0.3 fields (parts, tags, capabilities, defaultInputModes, defaultOutputModes, skills) — new requireArray / requireObject helpers in _validate.ts throw A2AError.invalidParams with the field path (e.g. message.parts is required and must be an array) instead of a native TypeError. Existing strict validation in toCoreMessage preserved.

Fixes #616 🦕

@JakubWorek
JakubWorek requested a review from a team as a code owner August 3, 2026 13:37
@github-actions

github-actions Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

🧪 Code Coverage

⬇️ Download Full Report

Base PR Delta
src/compat/v0_3/translate/agent_card.ts 91.66% 91.84% 🟢 +0.18%
src/compat/v0_3/translate/_validate.ts (new) — 100% —
Total 90.99% 91.01% 🟢 +0.02%

Generated by coverage-comment.yml

@JakubWorek
JakubWorek force-pushed the jakubworek/fix-issue-616 branch from ce21174 to 847d129 Compare August 4, 2026 09:06

@bartek-gralewicz bartek-gralewicz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I believe that we should reassess if this approach is the right one for this issue. The issue author mentions that our SDK crashed when an optional field was missing. This is a true bug and should be addressed but the changes in this PR, make required fields optional which should not be the case. Now, for missing required fields, there is no error, no warning, just silent accept with default values.

There is even a test 'does not crash when every declared-required field is missing at once'. This IMO is something we should revert and only fix handling missing optional fields.

Another comment from the issue author was that it would be nice to get some validation error when a required field is missing. If we want to touch required fields in this PR, I would suggest adding a helper method that takes the field or throws a user-friendly informative message saying which required field was missing. This could be a follow up as it doesn't fix the issue directly and is just a "nice to have". I am leaving the separation of these functionalities to your judgement.

@JakubWorek
JakubWorek merged commit 108736b into main Aug 5, 2026
17 checks passed
@JakubWorek
JakubWorek deleted the jakubworek/fix-issue-616 branch August 5, 2026 07:52
bartek-gralewicz added a commit that referenced this pull request Aug 26, 2026
🤖 I have created a release *beep* *boop*
---


## [1.1.0](v1.0.1...v1.1.0)
(2026-08-26)


### Features

* make event bus keep-alive states configurable
([#669](#669))
([f844dad](f844dad)),
closes [#620](#620)


### Bug Fixes

* Add serialization for listTasks input/output parameters.
([#610](#610))
([c863497](c863497))
* clone push notification configs before storing
([#662](#662))
([4d175a0](4d175a0))
* **compat/v0_3/translate:** add null and undefined checks to array and
string fields ([#618](#618))
([108736b](108736b))
* **deps:** replace `uuid` package with `crypto.randomUUID()`
([#665](#665))
([636b060](636b060))
* Do not filter tasks in ListTasks if task state is unspecified
([#622](#622))
([1c6eb32](1c6eb32))
* **errors:** global error branding via Symbol.hasInstance to fix
instanceof checks across bundle entry points
([#612](#612))
([cc33173](cc33173))
* **scripts:** update generate script to use buf and remove obsolete
generateTypes ([#653](#653))
([8bf3cd3](8bf3cd3))
* **server:** send full Task on every v0.3 push trigger
([#658](#658))
([b3afbe4](b3afbe4))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: bartek-gralewicz <[email protected]>
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]: Compat Client fails with a native 0.3 request wich does not provide optional fields

2 participants