Repository navigation
fix(compat/v0_3/translate): add null and undefined checks to array and string fields - #618
Conversation
🧪 Code Coverage
Generated by coverage-comment.yml |
ce21174 to
847d129
Compare
bartek-gralewicz
left a comment
There was a problem hiding this comment.
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.
…d in v0.3 translation layer
🤖 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]>
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:
Fixes #616 🦕