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

Tolerate missing field tags #246

Merged
merged 3 commits into from
Mar 1, 2024
Merged

Tolerate missing field tags #246

merged 3 commits into from
Mar 1, 2024

Conversation

Alfus
Copy link
Contributor

@Alfus Alfus commented Feb 29, 2024

While still returning an error. See #200
Note that the error occurs during validation instead of parsing to eventually allow algorithmic field tag assignments.

@Alfus Alfus marked this pull request as ready for review February 29, 2024 17:39
@Alfus Alfus requested a review from jhump February 29, 2024 17:39
ast/field.go Outdated Show resolved Hide resolved
ast/field.go Outdated Show resolved Hide resolved
Comment on lines +559 to +565
Error: `syntax = "proto2";
message Foo {
int32 bar = 1 [];
optional int32 bar = 1 [];
}`,
NoError: `syntax = "proto3";
NoError: `syntax = "proto2";
message Foo {
int32 bar = 1 [default=1];
optional int32 bar = 1 [default=1];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to preserve these testing a field declaration w/ no label, you could instead change the option from the proto3-disallowed default to something like json_name="foo".

Copy link
Contributor Author

@Alfus Alfus Mar 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I beleive label doesn't actually change the test coverage, it is testing the compact option rules only

parser/validate.go Outdated Show resolved Hide resolved
Copy link
Member

@jhump jhump left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool 👍

@Alfus Alfus merged commit f4c4a6f into main Mar 1, 2024
8 checks passed
@Alfus Alfus deleted the alfus/notag branch March 1, 2024 17:50
@bufdev
Copy link
Member

bufdev commented Mar 4, 2024

How do I turn the more lenient parsing off? There should be an option (for this, and anything else that was made more lenient), so that buf can enforce proper Protobuf

@jhump
Copy link
Member

jhump commented Mar 4, 2024

@bufdev, you don't need an option for that. All compile operations do the validation -- it's just been moved from the parse stage to the descriptor production/validation stage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants