[YANGTOOLS-776] min-elements and max-elements are not enforced Created: 17/May/17 Updated: 10/Apr/22 Resolved: 22/May/18 |
|
| Status: | Resolved |
| Project: | yangtools |
| Component/s: | None |
| Affects Version/s: | 1.2.2, 1.1.3, 2.0.4 |
| Fix Version/s: | 2.0.5 |
| Type: | Bug | ||
| Reporter: | Luis Gomez | Assignee: | Unassigned |
| 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: | 8496 |
| Description |
|
Just tried carbon archetype with this model:
module archcarbon {
yang-version 1;
namespace "urn:opendaylight:params:xml:ns:yang:archcarbon";
prefix "archcarbon";
revision "2015-01-05" {
description "Initial revision of archcarbon model";
}
container box {
list object {
key object-id;
leaf object-id {
type string;
}
leaf-list attributes {
type string;
min-elements 1;
max-elements 2;
}
}
}
}
Then tried PUT http://controller:8181/restconf/config/archcarbon:box/ with the bodies below: 1) Skip attributes is not allowed -> OK
{
"box": {
"object": [
{
"object-id":1,
}
]
}
}
2) Less attributes than min-elements is allowed -> NOK
{
"box": {
"object": [
{
"object-id":1,
"attributes": []
}
]
}
}
3) More attributes than max-elements is allowed -> NOK
{
"box": {
"object": [
{
"object-id":1,
"attributes": [
"object1",
"object2",
"object3"
]
}
]
}
}
|
| Comments |
| Comment by Robert Varga [ 04/May/18 ] |
|
It looks like MinMaxValidation is missing proper verifyStructure() checks. |
| Comment by Robert Varga [ 07/May/18 ] |
|
verifyStructure() is overly strict in what it does – combinations of an incomplete write() followed by a fixup end up being inconsistently enforced. At the end of the day, we need to catch this case in a uniform way, which seems to be when applyWrite() runs – it has the complete accurate view of what is about to be put into the tree. This has the downside of slowing down the commit thread, so it needs further analysis to see if there are cases we can offload to the user thread. |
| Comment by Luis Gomez [ 07/May/18 ] |
|
I do not think this is a critical issue as we can always use the cohort API to enforce the same, so if you think this feature is going to impact the overall controller performance we can skip it. If I was to push for something, that would be YANGTOOLS-834 as that cannot be enforced via cohort. |
| Comment by Robert Varga [ 21/May/18 ] |
|
The initial stab was almost correct – all it needed is to be activated only on full structural validation. |