protogen: Treat bytes field as non-nullable #123

Merged
fyrchik merged 1 commit from fyrchik/frostfs-api-go:fix-optional-bytes into master 2024-11-02 14:21:46 +00:00
Owner

In protobuf 3.12 they have added an support for optional keyword,
which has made it into the main branch in 3.15.
https://github.com/protocolbuffers/protobuf/blob/main/docs/implementing_proto3_presence.md
https://github.com/protocolbuffers/protobuf/blob/v3.12.0/docs/field_presence.md#presence-in-proto3-apis

This means that without an explicit optional keyword field presence
for scalars is not tracked, thus empty string in JSON should be
unmarshaled to a nil byte slice. Relevant decoding code and tests from
protojson:
fb995f184a/internal/impl/message_reflect_field.go (L327)
fb995f184a/encoding/protojson/decode_test.go (L134)
fb995f184a/encoding/protojson/decode_test.go (L156)

We do not support optional keyword and the generator will fail if it sees on.
So only implement the default behaviour.

Refs #122

Signed-off-by: Evgenii Stratonikov e.stratonikov@yadro.com

In protobuf 3.12 they have added an support for `optional` keyword, which has made it into the main branch in 3.15. https://github.com/protocolbuffers/protobuf/blob/main/docs/implementing_proto3_presence.md https://github.com/protocolbuffers/protobuf/blob/v3.12.0/docs/field_presence.md#presence-in-proto3-apis This means that without an explicit `optional` keyword field presence for scalars is not tracked, thus empty string in JSON should be unmarshaled to a nil byte slice. Relevant decoding code and tests from protojson: https://github.com/protocolbuffers/protobuf-go/blob/fb995f184a1719ec42b247a3771d1036d92adf67/internal/impl/message_reflect_field.go#L327 https://github.com/protocolbuffers/protobuf-go/blob/fb995f184a1719ec42b247a3771d1036d92adf67/encoding/protojson/decode_test.go#L134 https://github.com/protocolbuffers/protobuf-go/blob/fb995f184a1719ec42b247a3771d1036d92adf67/encoding/protojson/decode_test.go#L156 We do not support `optional` keyword and the generator will fail if it sees on. So only implement the default behaviour. Refs #122 Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
fyrchik added 1 commit 2024-10-11 07:21:09 +00:00
protogen: Treat bytes field as non-nullable
Some checks failed
Tests and linters / Lint (pull_request) Failing after 53s
DCO action / DCO (pull_request) Failing after 1m35s
Tests and linters / Tests (pull_request) Successful in 1m38s
Tests and linters / Tests with -race (pull_request) Successful in 1m39s
7aebd82a84
In protobuf 3.12 they have added an support for `optional` keyword,
which has made it into the main branch in 3.15.
https://github.com/protocolbuffers/protobuf/blob/main/docs/implementing_proto3_presence.md
https://github.com/protocolbuffers/protobuf/blob/v3.12.0/docs/field_presence.md#presence-in-proto3-apis

This means that without an explicit `optional` keyword field presence
for scalars is not tracked, thus empty string in JSON should be
unmarshaled to a nil byte slice. Relevant decoding code and tests from
protojson:
fb995f184a/internal/impl/message_reflect_field.go (L327)
fb995f184a/encoding/protojson/decode_test.go (L134)
fb995f184a/encoding/protojson/decode_test.go (L156)

We do not support `optional` keyword and the generator will fail if it sees on.
So only implement the default behaviour.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
fyrchik force-pushed fix-optional-bytes from 7aebd82a84 to fdf56fabe5 2024-10-11 07:21:38 +00:00 Compare
fyrchik requested review from alexvanin 2024-10-11 07:26:12 +00:00
fyrchik requested review from storage-core-committers 2024-10-11 07:26:13 +00:00
fyrchik requested review from storage-core-developers 2024-10-11 07:26:13 +00:00
fyrchik added 1 commit 2024-10-11 07:29:03 +00:00
[#123] Resolve funlen linter issue
All checks were successful
Tests and linters / Lint (pull_request) Successful in 47s
DCO action / DCO (pull_request) Successful in 1m13s
Tests and linters / Tests (pull_request) Successful in 1m14s
Tests and linters / Tests with -race (pull_request) Successful in 1m14s
84060ce16a
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
acid-ant approved these changes 2024-10-11 08:54:58 +00:00
Dismissed
fyrchik force-pushed fix-optional-bytes from 84060ce16a to bba4af93d6 2024-10-11 11:40:17 +00:00 Compare
fyrchik dismissed acid-ant's review 2024-10-11 11:40:17 +00:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

fyrchik force-pushed fix-optional-bytes from bba4af93d6 to f0fc40e116 2024-10-11 11:40:59 +00:00 Compare
Author
Owner

Whitespace changes only.

Whitespace changes only.
fyrchik merged commit f0fc40e116 into master 2024-10-11 12:15:46 +00:00
fyrchik referenced this pull request from a commit 2024-10-11 12:15:47 +00:00
fyrchik deleted branch fix-optional-bytes 2024-10-11 12:15:48 +00:00
Sign in to join this conversation.
No reviewers
TrueCloudLab/storage-core-developers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-api-go#123
No description provided.