[YANGTOOLS-608] Mandatory leaf enforcement is not correct with presence container Created: 02/May/16 Updated: 10/Apr/22 Resolved: 07/Jun/16 |
|
| Status: | Resolved |
| Project: | yangtools |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | ||
| Reporter: | Tom Pantelis | Assignee: | Peter Kajsa |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Operating System: All |
||
| External issue ID: | 5830 |
| Priority: | Normal |
| Description |
|
Given the following schema: container task-container { leaf task-id { type string; } container task-data { leaf other-data { type string; } } If one PUTs: task: { task-id: "123" }it succeeds as expected without specifying the mandatory descendant leaf "mandatory-data" because its immediate ancestor, "task-data", is a presence container and it wasn't specified. This conforms to https://tools.ietf.org/html/rfc6020#section-7.6.5 (the 3rd constraint bullet below): If "mandatory" is "true", the behavior of the constraint depends on o If no such ancestor exists in the schema tree, the leaf MUST o Otherwise, if this ancestor is a case node, the leaf MUST exist if o Otherwise, the leaf MUST exist if the ancestor node exists in the Therefore "mandatory-data" doesn't need to exist b/c "task-data" doesn't exist. If one PUTs: task: { } it also succeeds. However, in this case, "task-data" is present so this seems to violate the 3rd constraint above, i.e. it should've failed b/c "mandatory-data" was not specified. |
| Comments |
| Comment by Tom Pantelis [ 03/May/16 ] |
|
I found another case which looks like a bug. If container "task-data" in the schema above is not a presence container the writing: task: { } fails as expected b/c "mandatory-data" was not specified. However if the "task" list is removed from the schema, i.e.: container task-container { container task-data { leaf other-data { type string; } } writing: task-container: { } succeeds. This also seems to violate the RFC. Mandatory leafs are only enforced when descendants of a list. |
| Comment by Tom Pantelis [ 03/May/16 ] |
|
Another inconsistency. Given the original schema with the "task" list but "task-data" non-presence, writing task-container: { } succeeds but it should fail. |
| Comment by Robert Varga [ 03/May/16 ] |
|
The two later cases are expected, as mandatory leaf enforcement is not performing validation based on RFC6020 Section 7.6.5 bullet 1, as that would require all mandatory leaves to be introduced in the first transaction that occurs – any other transactions would fail. We do not have a mechanism which could reliably satisfy that requirement. |
| Comment by Colin Dixon [ 03/May/16 ] |
|
Should we open an enhancement bug to allow people to voluntarily enable mandatory enforcement per the RFC 6020 on some basis. For example, could somebody turn it on a per-module basis sometime after boot? |
| Comment by Colin Dixon [ 03/May/16 ] |
|
During the MD-SAL call today, we confirmed that at least the first part here is a real bug. That is if a presence container exists, its mandatory child leaves must also exist. |
| Comment by Peter Kajsa [ 25/May/16 ] |
|
(In reply to Colin Dixon from comment #5) |
| Comment by Robert Varga [ 07/Jun/16 ] |