Skip to content

fix(datastore): Handle loading nil values - #8544

Merged
bhshkh merged 7 commits into
googleapis:mainfrom
bhshkh:fix/issue-8325
Sep 18, 2023
Merged

bhshkh merged 7 commits into
googleapis:mainfrom
bhshkh:fix/issue-8325

Conversation

@bhshkh

@bhshkh bhshkh commented Sep 11, 2023 •

Copy link
Copy Markdown
Contributor

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 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
Comment thread datastore/load.go Resolved
Comment thread datastore/load_test.go Resolved
Comment thread datastore/load_test.go 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
@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

⌂ 换网址