Skip to content

Conversation

@le-michael
Copy link
Contributor

Fixes #7709

@github-actions github-actions bot added c++ codegen Involving generating code from schema golang labels Dec 18, 2022
@le-michael le-michael changed the title [Go] Perform nil check on string fields when packing object api [Go] Perform empty string check on string fields when packing objects Dec 18, 2022
@dbaileychess dbaileychess enabled auto-merge (squash) December 22, 2022 20:21
@dbaileychess dbaileychess merged commit 96d438d into google:master Dec 22, 2022
sunwen18 pushed a commit to sunwen18/flatbuffers that referenced this pull request Dec 25, 2022
Co-authored-by: Derek Bailey <derekbailey@google.com>
razvanalex added a commit to razvanalex/flatbuffers that referenced this pull request Sep 23, 2024
In C++, CreateX allows to write the default "" value of a required
string, when the string is not explicitly set. Object API Pack method
uses this implementation of CreateX.

However, in go, despite whether the field is optional or required, it is
always checked against empty string allowing to create messages that
fail to pass the verifier. This commits partially reverts
flatbuffers/google#7719 when the string field is required.
razvanalex added a commit to razvanalex/flatbuffers that referenced this pull request Sep 24, 2024
In C++, CreateX allows to write the default "" value of a required
string, when the string is not explicitly set. Object API Pack method
uses this implementation of CreateX.

However, in go, despite whether the field is optional or required, it is
always checked against empty string allowing to create messages that
fail to pass the verifier. This commits partially reverts google#7719 when the
string field is required.
jochenparm pushed a commit to jochenparm/flatbuffers that referenced this pull request Oct 29, 2024
Co-authored-by: Derek Bailey <derekbailey@google.com>
jochenparm pushed a commit to jochenparm/flatbuffers that referenced this pull request Oct 29, 2024
Co-authored-by: Derek Bailey <derekbailey@google.com>
razvanalex added a commit to razvanalex/flatbuffers that referenced this pull request Dec 3, 2024
In C++, CreateX allows to write the default "" value of a required
string, when the string is not explicitly set. Object API Pack method
uses this implementation of CreateX.

However, in go, despite whether the field is optional or required, it is
always checked against empty string allowing to create messages that
fail to pass the verifier. This commits partially reverts google#7719 when the
string field is required.
jtdavis777 pushed a commit that referenced this pull request Dec 1, 2025
…PI (#8402)

* [Go] Write required string fields into the buffer when using Object API

In C++, CreateX allows to write the default "" value of a required
string, when the string is not explicitly set. Object API Pack method
uses this implementation of CreateX.

However, in go, despite whether the field is optional or required, it is
always checked against empty string allowing to create messages that
fail to pass the verifier. This commits partially reverts #7719 when the
string field is required.

* Add test for serializing required string fields using Object API

* Update generated code

The Monster schema contains a key string field. For historical
convenience reasons, string keys are assumed required.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ codegen Involving generating code from schema golang

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Go] Object API encodes empty strings

2 participants