Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(datastore): Handle loading nil values #8544

Merged
merged 7 commits into from Sep 18, 2023

Conversation

bhshkh
Copy link
Contributor

@bhshkh bhshkh commented Sep 11, 2023

Issue: In Go, any datatype is an alias for empty interface.
Getting entities with nil values in empty interface causes panic.
For sample code, please see: #8325 (comment)

Cause: When a reflect value is untyped nil, its type cannot be determined by using Type(). The code panics with error: call of reflect.Value.Type on zero Value

Fix: If the field being set is an interface and the value to set is untyped nil, set the field to zero value.

@bhshkh bhshkh requested review from a team as code owners September 11, 2023 02:15
@product-auto-label product-auto-label bot added size: s Pull request size is small. api: datastore Issues related to the Datastore API. labels Sep 11, 2023
@bhshkh bhshkh requested a review from enocom September 11, 2023 02:16
@bhshkh bhshkh enabled auto-merge (squash) September 11, 2023 02:33
@bhshkh bhshkh marked this pull request as draft September 11, 2023 02:59
auto-merge was automatically disabled September 11, 2023 02:59

Pull request was converted to draft

@bhshkh bhshkh marked this pull request as ready for review September 11, 2023 03:16
@bhshkh bhshkh enabled auto-merge (squash) September 11, 2023 16:59
datastore/load.go Show resolved Hide resolved
datastore/load_test.go Show resolved Hide resolved
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Sep 15, 2023
@bhshkh bhshkh linked an issue Sep 18, 2023 that may be closed by this pull request
@bhshkh bhshkh merged commit 25dbb9c into googleapis:main Sep 18, 2023
9 checks passed
@bhshkh bhshkh deleted the fix/issue-8325 branch September 18, 2023 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the Datastore API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

datastore: can't put null into any type
4 participants