Repository navigation
fix(sidekick/swift): preserve null WKT presence - #7919
Merged
Merged
Conversation
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
Contributor
There was a problem hiding this comment.
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
marked this pull request as ready for review
November 12, 2026 20:07
chingor13
approved these changes
Nov 12, 2026
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Update the Swift code generator in sidekick to preserve explicit JSON null presence for singular, optional, and oneof fields of type
google.protobuf.Valueandgoogle.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