flatbuffers icon indicating copy to clipboard operation
flatbuffers copied to clipboard

Parsing from proto should keep field ID. (fixes #7645)

Open enum-class opened this issue 3 years ago • 2 comments

Fix issue #7645. When parsing from a proto that have explicit field identifiers, flatbuffers need to keep those identifiers stable by explicitly using the id attribute. This is because protos allow new field placement anywhere in their message, even before other fields, as long as they use a new field ID.

enum-class avatar Nov 20 '22 01:11 enum-class

Under construction ...

enum-class avatar Nov 20 '22 02:11 enum-class

@dbaileychess could you please help me with review this ?

enum-class avatar Nov 22 '22 02:11 enum-class

Hello @dbaileychess , I found in parser for union add a second auto-generated vector field to hold the types, with a special suffix. The generated field will get id equal to union id minus 1 : Link I wonder if this is a correct behavior for parser or not ? Is this documented ? Actually, It violates consecutive invariant id rules. because it force fbs writer to reserve an id before union id . You can find In monster tests that we do not use id 7, because union wants to use it, And if we use this id, It wont generate code

enum-class avatar Dec 04 '22 16:12 enum-class

Hello @dbaileychess , I found in parser for union add a second auto-generated vector field to hold the types, with a special suffix. The generated field will get id equal to union id minus 1 : Link I wonder if this is a correct behavior for parser or not ? Is this documented ? Actually, It violates consecutive invariant id rules. because it force fbs writer to reserve an id before union id . You can find In monster tests that we do not use id 7, because union wants to use it, And if we use this id, It wont generate code

See https://le-michael.github.io/flatbuffers-doc-demo/Schemas.html#attributes on id. We do mention that Unions have two fields associated with them, the Union value N and an implicit hidden Union-Type N-1.

dbaileychess avatar Dec 05 '22 17:12 dbaileychess

Hello @dbaileychess

  1. Can you help me with buildifier check
  2. What should I do about --conform ? What is final decision about it ?
  3. It seems ready to review. Could you please review it ?

enum-class avatar Dec 10 '22 03:12 enum-class

@enum-class Let me get back to you on this.

dbaileychess avatar Dec 13 '22 05:12 dbaileychess

For conform, lets just output a message (warning level) that when you use --proto, that you should check for conformity yourself, using the existing --conform implementation.

The builtkite isn't a build cleaner, but another CI platform for bazel. The error looks temporary to me, so lets just try retriggering it.

dbaileychess avatar Dec 13 '22 06:12 dbaileychess

Oops, you meant the buildifer within builtkite. That can be fixed automatically with the following command:

buildifier tests/BUILD.bazel

dbaileychess avatar Dec 13 '22 06:12 dbaileychess

Looks like you need to alphabetize the entries, if you don't want to download buildifer

dbaileychess avatar Dec 13 '22 06:12 dbaileychess

Thank you for your time, Great review, I love it

enum-class avatar Dec 13 '22 23:12 enum-class

@dbaileychess Could please help me with review this p.r.

enum-class avatar Jan 04 '23 14:01 enum-class

@dbaileychess This tiny p.r. from last year needs review :)

enum-class avatar Jan 10 '23 05:01 enum-class

@enum-class Sorry for missing this, I will get to it today or tomorrow.

dbaileychess avatar Jan 10 '23 16:01 dbaileychess

Going to approve this now. Since it is a new feature, we can fix forward any issues.

dbaileychess avatar Feb 01 '23 19:02 dbaileychess