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

protoc: parser rejects explicit use of map_entry option #13479

Closed
wants to merge 2 commits into from

Conversation

jhump
Copy link
Contributor

@jhump jhump commented Aug 9, 2023

This addresses #13441.

This preserves the similar check at the point of use of invalid messages in DescriptorBuilder (and there's an existing test that verifies that check still works).

But it adds another check in the parser, to catch this error at the point of definition of an invalid message. And the corresponding test is updated: we no longer need a usage of the message to catch the error, and the reported position is the definition of the option, not the usage site of the message.

The way this works feels kinda gross, but I wasn't sure of a better way to do it. The only place we know for certain that it was an explicit option (vs. auto-added by the parser when synthesizing a map entry message) is when after processing the message body, we can look at the uninterpreted options. So that's what this does. If you have ideas on better/cleaner approaches, I'd be happy to revise.

@jhump jhump requested a review from a team as a code owner August 9, 2023 00:23
@jhump jhump requested review from sbenzaquen and removed request for a team August 9, 2023 00:23
@fowles fowles added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Aug 9, 2023
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Aug 9, 2023
@fowles
Copy link
Contributor

fowles commented Aug 9, 2023

this one also requires a google3 cleanup although substantially smaller than the other

@jhump
Copy link
Contributor Author

jhump commented Aug 9, 2023

@fowles, so does that mean that there are places in the google3 codebase that were using explicit map_entry options? And the other failing build means reserved ranges where start and end were reversed?

BTW, sorry if this makes more work for your team. These are obviously not urgent fixes. And thanks for your help in shepherding these fixes into the codebase!

@fowles
Copy link
Contributor

fowles commented Aug 9, 2023

yes, the cleanups are simple so I should be able to slice them in this week

copybara-service bot pushed a commit that referenced this pull request Aug 10, 2023
This addresses #13441.

This preserves the similar check at the _point of use_ of invalid messages in `DescriptorBuilder` (and there's an existing test that verifies that check still works).

But it adds another check in the parser, to catch this error at the _point of definition_ of an invalid message. And the corresponding test is updated: we no longer need a usage of the message to catch the error, and the reported position is the definition of the option, not the usage site of the message.

The way this works feels kinda gross, but I wasn't sure of a better way to do it. The only place we know for certain that it was an explicit option (vs. auto-added by the parser when synthesizing a map entry message) is when after processing the message body, we can look at the uninterpreted options. So that's what this does. If you have ideas on better/cleaner approaches, I'd be happy to revise.

Closes #13479

COPYBARA_INTEGRATE_REVIEW=#13479 from jhump:jh/map-option-not-allowed 4d95e9b
FUTURE_COPYBARA_INTEGRATE_REVIEW=#13479 from jhump:jh/map-option-not-allowed 4d95e9b
PiperOrigin-RevId: 555548662
copybara-service bot pushed a commit that referenced this pull request Aug 10, 2023
This addresses #13441.

This preserves the similar check at the _point of use_ of invalid messages in `DescriptorBuilder` (and there's an existing test that verifies that check still works).

But it adds another check in the parser, to catch this error at the _point of definition_ of an invalid message. And the corresponding test is updated: we no longer need a usage of the message to catch the error, and the reported position is the definition of the option, not the usage site of the message.

The way this works feels kinda gross, but I wasn't sure of a better way to do it. The only place we know for certain that it was an explicit option (vs. auto-added by the parser when synthesizing a map entry message) is when after processing the message body, we can look at the uninterpreted options. So that's what this does. If you have ideas on better/cleaner approaches, I'd be happy to revise.

Closes #13479

COPYBARA_INTEGRATE_REVIEW=#13479 from jhump:jh/map-option-not-allowed 4d95e9b
FUTURE_COPYBARA_INTEGRATE_REVIEW=#13479 from jhump:jh/map-option-not-allowed 4d95e9b
PiperOrigin-RevId: 555548662
copybara-service bot pushed a commit that referenced this pull request Aug 12, 2023
This addresses #13441.  Second try, now with more internal fixes.

This preserves the similar check at the _point of use_ of invalid messages in `DescriptorBuilder` (and there's an existing test that verifies that check still works).

But it adds another check in the parser, to catch this error at the _point of definition_ of an invalid message. And the corresponding test is updated: we no longer need a usage of the message to catch the error, and the reported position is the definition of the option, not the usage site of the message.

The way this works feels kinda gross, but I wasn't sure of a better way to do it. The only place we know for certain that it was an explicit option (vs. auto-added by the parser when synthesizing a map entry message) is when after processing the message body, we can look at the uninterpreted options. So that's what this does. If you have ideas on better/cleaner approaches, I'd be happy to revise.

Closes #13479

PiperOrigin-RevId: 556335288
copybara-service bot pushed a commit that referenced this pull request Aug 15, 2023
This addresses #13441.  Second try, now with more internal fixes.

This preserves the similar check at the _point of use_ of invalid messages in `DescriptorBuilder` (and there's an existing test that verifies that check still works).

But it adds another check in the parser, to catch this error at the _point of definition_ of an invalid message. And the corresponding test is updated: we no longer need a usage of the message to catch the error, and the reported position is the definition of the option, not the usage site of the message.

The way this works feels kinda gross, but I wasn't sure of a better way to do it. The only place we know for certain that it was an explicit option (vs. auto-added by the parser when synthesizing a map entry message) is when after processing the message body, we can look at the uninterpreted options. So that's what this does. If you have ideas on better/cleaner approaches, I'd be happy to revise.

Closes #13479

PiperOrigin-RevId: 557199190
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.

2 participants