-
Notifications
You must be signed in to change notification settings - Fork 546
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
Schema compatibility rule for removing optional fields is inconsistent with other rules #54
Comments
It should be an error.We should modify the error message to make it clear why it is considered incompatible in the included message, e.g. "because new field may be added with the same name but different type in the future" |
Thanks Swee. I'll submit a pull request. |
We have had discussions amongst ourselves internally at LinkedIn and we have always felt this needed to be fixed. Let me circle back with others and get back to you. Have you already submitted a pull request for this? |
Nope, I have not submitted a pull request. I'm glad you're already thinking about this. At Google, they deal with protobuf in a similar way. Once a tag field has been used in a Pegasus currently has the notion of "deprecated". Maybe once this fix is in place, it would be worth having an even stronger form of obsoleteness? E.g. But here's what I would probably do:
The best existing "Impact" i found for this case is It might be worth expanding on the message more. |
Yes that message sounds like what Swee was suggesting too. Do you want to submit a pull request for this eventually? Otherwise I will open a ticket which will be used for tracking this at work. I can't give an estimate on when we would fix it though. |
I'll send a pull request in the next week for so. On Monday, August 10, 2015, Karim Vidhani notifications@github.com wrote:
|
Any update on this? |
This issue represents a trade-off between safety (pull request) and flexibility (current code). The risk of an incompatible re-addition of a removed field is low, so arguably it’s worth taking in order to allow for cleaner schema evolution. For instance, the current approach encourages expressive schemas, even when a field is known upfront to have a short lifespan. I propose adding an _allowFieldRemoval field to CompatibilityOptions, which would control whether removing an optional field is considered an error. That would allow users to choose the approach that works for them. The current code is inconsistent in that it considers removing an optional field not an error, but considers removing a non-optional field with a default value an error. I propose fixing that by making the new option above also control whether removing a field with a default value is considered an error. |
@eranl This sounds reasonable to me. We're basically saying that in addition to what we're proposing in this pull request, we will allow users to ignore a compatibility checker error they consider overly strict for their purposes, similar to how compilers and linters allow various warnings to be enabled/disabled. |
How often, if ever, will people configure the compat checker before running it? Most people won't even know that this option to configure even exists. Therefore:
|
Currently, the options are hard-coded, but I think they should be exposed through RestLiResourceModelCompatibilityChecker and PegasusPlugin, so that build scripts can control them. To clarify, my expectation is that these options would configured at the rest.li installation level rather than by individual developers. |
@kvidhani How should we proceed? Is this work that the rest.li team will take on? |
I am comfortable with making this change (forbidding removing optional Is this acceptable?
On Thu, Jul 14, 2016 at 2:12 PM, Joe Betz notifications@github.com wrote:
|
@kvidhani That sounds reasonable to me. If later there is a compelling use case for introducing options, they could always be added later. |
I'm opening a jira to track this. How high of a priority do you think this
On Fri, Jul 15, 2016 at 12:19 PM, Joe Betz notifications@github.com wrote:
|
@kvidhani I'm not aware of anyone blocked by this. It would conclude some of the discussions around the consistency of the compatibility checker rules, but isn't really urgent. The good news is that the only work do be done review and then commit this PR. |
@jpbetz We have a rest.li bug scheduling session coming up. I'll make sure this is scheduled and taken care of soon. As part of this JIRA, we will review the pull request, commit it, update the documentation and close this discussion. Will this suffice? |
Sounds great to me. It's a tiny change (like 5 lines) so should literally take 5 minutes. |
closing hopelessly stale issues I've opened |
In CompatibilityChecker the removing an optional field is not considered an error. As a result it is not considered an error to remove an optional field and then add a new optional field with the same field name as the field just removed, but with a different type. This is clearly inconsistent with the rule that it is a compatibility error to change the type of field.
Consider this case:
string
exists in a record schema.string
when present.Title
(a record type). This also is not considered an error according to CompatibilityChecker.It is now possible to have writers producing either a string or a record for the 'title' field. It is also possible to have readers expecting either a string or a record for the field. They are clearly not compatible with one another.
I believe the correct fix it to make removing optional fields a compatibility error.
The text was updated successfully, but these errors were encountered: