Skip to content

fix(sidekick/swift): preserve null WKT presence - #7919

Merged
coryan merged 1 commit into
googleapis:mainfrom
coryan:fix-issue-1612
Nov 12, 2026
Merged

coryan merged 1 commit into
googleapis:mainfrom
coryan:fix-issue-1612

Conversation

@coryan

@coryan coryan commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Update the Swift code generator in sidekick to preserve explicit JSON null presence for singular, optional, and oneof fields of type google.protobuf.Value and google.protobuf.NullValue.

Previously, generated Decodable initializers called decodeIfPresent for all optional and oneof fields, which drops explicit JSON null entries to nil instead of decoding WKTValue.null or WKTNullValue. Generated initializers now check container.contains for the field key and call container.decode directly so explicit null values remain distinct from omitted fields while repeated and map fields keep their existing decoding.

For googleapis/google-cloud-swift#1612

Draft in googleapis/google-cloud-swift#1618

Update the Swift code generator in sidekick to preserve explicit JSON
null presence for singular, optional, and oneof fields of type
google.protobuf.Value and google.protobuf.NullValue.

Previously, generated Decodable initializers called decodeIfPresent for
all optional and oneof fields, which drops explicit JSON null entries to
nil instead of decoding WKTValue.null or WKTNullValue. Generated
initializers now check container.contains for the field key and call
container.decode directly so explicit null values remain distinct from
omitted fields while repeated and map fields keep their existing decoding.

For googleapis/google-cloud-swift#1612

@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 introduces support for preserving explicit JSON null values in Swift code generation by identifying fields of type google.protobuf.Value or google.protobuf.NullValue and applying a specialized decoding strategy. The feedback highlights a critical issue in the generated templates where decoding a non-optional type from an explicit null value will throw a DecodingError.valueNotFound. To resolve this, the reviewer suggests a safer decoding pattern using decodeIfPresent and superDecoder to correctly handle explicit nulls.

coryan added a commit to coryan/google-cloud-swift that referenced this pull request Nov 12, 2026
Verify that WKTValue and WKTNullValue explicit-null decoding and
encoding roundtrips succeed with Foundation.JSONDecoder (as well as
_ProtoJSONDecoder), falsifying the concern that KeyedDecodingContainer
throws valueNotFound on explicit JSON null for these types in
googleapis/librarian#7919.
@coryan
coryan marked this pull request as ready for review November 12, 2026 20:07
@coryan
coryan requested a review from a team as a code owner November 12, 2026 20:07
@coryan
coryan merged commit d4f31e9 into googleapis:main Nov 12, 2026
50 of 51 checks passed
@coryan
coryan deleted the fix-issue-1612 branch November 12, 2026 21:21
coryan added a commit to coryan/google-cloud-swift that referenced this pull request Nov 12, 2026
Regenerate client libraries and ProtoJSON test models using the
sidekick/swift explicit-null decoding changes from
googleapis/librarian#7919.

For singular, optional, and oneof fields of type GoogleWKT.WKTValue
and GoogleWKT.WKTNullValue, generated Decodable initializers now check
container.contains before calling container.decode directly so explicit
JSON null values preserve field presence instead of decoding to nil.

Note: librarian.yaml is not bumped in this commit and must be updated
once googleapis/librarian#7919 merges.

For googleapis#1612
coryan added a commit to coryan/google-cloud-swift that referenced this pull request Nov 12, 2026
Verify that WKTValue and WKTNullValue explicit-null decoding and
encoding roundtrips succeed with Foundation.JSONDecoder (as well as
_ProtoJSONDecoder), falsifying the concern that KeyedDecodingContainer
throws valueNotFound on explicit JSON null for these types in
googleapis/librarian#7919.
coryan added a commit to googleapis/google-cloud-swift that referenced this pull request Nov 12, 2026
Companion PR to googleapis/librarian#7919
showing the regenerated Swift output and ProtoJSON tests for #1612.

`librarian.yaml` will be bumped once googleapis/librarian#7919 merges.
chingor13 pushed a commit to googleapis/swift-google-cloud-enterpriseknowledgegraph-v1 that referenced this pull request Nov 13, 2026
Companion PR to googleapis/librarian#7919
showing the regenerated Swift output and ProtoJSON tests for #1612.

`librarian.yaml` will be bumped once googleapis/librarian#7919 merges.
chingor13 pushed a commit to googleapis/swift-google-cloud-recommender-v1 that referenced this pull request Nov 13, 2026
Companion PR to googleapis/librarian#7919
showing the regenerated Swift output and ProtoJSON tests for #1612.

`librarian.yaml` will be bumped once googleapis/librarian#7919 merges.
chingor13 pushed a commit to googleapis/swift-google-cloud-orgpolicy-v2 that referenced this pull request Nov 13, 2026
Companion PR to googleapis/librarian#7919
showing the regenerated Swift output and ProtoJSON tests for #1612.

`librarian.yaml` will be bumped once googleapis/librarian#7919 merges.
chingor13 pushed a commit to googleapis/swift-google-cloud-aiplatform-v1 that referenced this pull request Nov 13, 2026
Companion PR to googleapis/librarian#7919
showing the regenerated Swift output and ProtoJSON tests for #1612.

`librarian.yaml` will be bumped once googleapis/librarian#7919 merges.
chingor13 pushed a commit to googleapis/swift-google-cloud-ces-v1 that referenced this pull request Nov 13, 2026
Companion PR to googleapis/librarian#7919
showing the regenerated Swift output and ProtoJSON tests for #1612.

`librarian.yaml` will be bumped once googleapis/librarian#7919 merges.
chingor13 pushed a commit to googleapis/swift-google-cloud-connectors-v1 that referenced this pull request Nov 13, 2026
Companion PR to googleapis/librarian#7919
showing the regenerated Swift output and ProtoJSON tests for #1612.

`librarian.yaml` will be bumped once googleapis/librarian#7919 merges.
chingor13 pushed a commit to googleapis/swift-google-cloud-config-v1 that referenced this pull request Nov 13, 2026
Companion PR to googleapis/librarian#7919
showing the regenerated Swift output and ProtoJSON tests for #1612.

`librarian.yaml` will be bumped once googleapis/librarian#7919 merges.
chingor13 pushed a commit to googleapis/swift-google-cloud-dialogflow-cx-v3 that referenced this pull request Nov 13, 2026
Companion PR to googleapis/librarian#7919
showing the regenerated Swift output and ProtoJSON tests for #1612.

`librarian.yaml` will be bumped once googleapis/librarian#7919 merges.
chingor13 pushed a commit to googleapis/swift-google-cloud-dialogflow-v2 that referenced this pull request Nov 13, 2026
Companion PR to googleapis/librarian#7919
showing the regenerated Swift output and ProtoJSON tests for #1612.

`librarian.yaml` will be bumped once googleapis/librarian#7919 merges.
chingor13 pushed a commit to googleapis/swift-google-cloud-oracledatabase-v1 that referenced this pull request Nov 13, 2026
Companion PR to googleapis/librarian#7919
showing the regenerated Swift output and ProtoJSON tests for #1612.

`librarian.yaml` will be bumped once googleapis/librarian#7919 merges.
chingor13 pushed a commit to googleapis/swift-google-cloud-policytroubleshooter-iam-v3 that referenced this pull request Nov 13, 2026
Companion PR to googleapis/librarian#7919
showing the regenerated Swift output and ProtoJSON tests for #1612.

`librarian.yaml` will be bumped once googleapis/librarian#7919 merges.
hj690 pushed a commit that referenced this pull request Nov 16, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.53.0](v0.52.0...v0.53.0)
(2026-11-16)


### Features

* **ruby:** batch rubocop formatting across generated libraries
([#7807](#7807))
([94d52a0](94d52a0))


### Bug Fixes

* **internal/sidekick:** preserve explicit empty routing annotations
([#7927](#7927))
([4c09196](4c09196))
* **sidekick/swift:** preserve null WKT presence
([#7919](#7919))
([d4f31e9](d4f31e9))

---
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: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
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