-
Notifications
You must be signed in to change notification settings - Fork 76
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
Enforce that entity field is always structure type #1053
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ktuite
commented
Dec 1, 2023
ktuite
changed the title
Better handling of entity tag with no children
Enforce that entity field is always structure type
Dec 1, 2023
ktuite
commented
Dec 1, 2023
This was
linked to
issues
Dec 5, 2023
ktuite
commented
Dec 6, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interactive review with @matthew-white
matthew-white
approved these changes
Dec 6, 2023
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In response to getodk/central#551, getodk/central#552, and getodk/central#552
It was the case that the whether or not the
<entity>
block had a child like<label>
would change the type of field that entity was fromstructure
(if it had children) tounknown
. This lead to each of the errors above.Example 1: This is possible for an update form that doesn't update an entity's label, but wasn't really possible before because a label was needed to create an entity.
Example 2: This was the only kind of form we saw before, where
entity
was always structural.The main change in this PR is forcing the entity field, which so far is always at
/meta/entity
to be structural, even if it is empty.What has been done to verify that this works as intended?
Tests.
Why is this the best possible solution? Were any other approaches considered?
This is the simplest approach. The code change is small, if solves a bunch of issues at once.
The other option we considered was not changing the field type and adding workarounds for when
entity
wasunknown
. But these were getting cumbersome and likely hard/annoying to maintain or work around in the future.How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Risk 1: The fact that
entity
can be an empty structural node might cause some problems somewhere. There are places in the code that use the structure type of the field to recurse over children. That could lead to a problem that we haven't realized yet. The entity field is the only one that gets this treatment, though, so the problem would be contained to those fields and those label-less update forms.We want to check exports and OData because that is where, if there were a problem, it would probably come up.
Risk 2: It's unlikely that people got forms into the system that had
<entity>
blocks without labels/children that got saved as typeunknown
... but maybe? We could add a migration to make sure all meta/entity fields are structural. Or we could not, because it's probably not common. It would have to be a super old form that someone is oddly committed to upgrading rather than replacing to run into this problem at all.Does this change require updates to the API documentation? If so, please update docs/api.md as part of this PR.
Luckily no.
Before submitting this PR, please make sure you have:
make test-full
and confirmed all checks still pass OR confirm CircleCI build passes