review_tools complains about netlink_driver having a string value in snap declaration
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
review-tools |
Fix Released
|
Undecided
|
Emilia Torino |
Bug Description
This plug declaration :
{
"allow-
{
"
"whatever"
],
"slot-names": [
],
"
"family": "24",
},
"
},
"on-store": [
]
}
]
}
and a snap with this in the snap.yaml:
slots:
netlink-foo:
interface: netlink-driver
family: 24
family-name: a-family
results in review-tools complaining as follows:
- declaration malformed (wrong type '24' for attribute 'family') declaration-
Looking at review-tools' interface_attribs I think review-tools wants the value in the snap-declaration to be an integer, but if I try to change the snap-declaration to:
"
"family": 24, <-------------- Making this an int
},
then I can't even save the snap declaration:
netlink-driver must be a json-serialized dict. Dicts and lists are allowed as values, scalar values must be strings.
Does review-tools need to also (or instead) accept a string for "family"?
Related branches
- Samuele Pedroni (community): Approve
-
Diff: 178 lines (+103/-17)2 files modifiedreviewtools/sr_declaration.py (+26/-7)
reviewtools/tests/test_sr_declaration.py (+77/-10)
Changed in review-tools: | |
assignee: | nobody → Emilia Torino (emitorino) |
Apologies, looks like that lateral validation is done in the Snap Store dashboard code, this is applied to the dictionary and it clearly will barf on anything that's not a list, dict or string (lists and dicts must additionally also contain only lists, dicts or strings themselves).
def _valid_ items(items) :
is_ valid = (
isinstance( item, basestring) items(item. values( )))
raise ValidationError (error_ msg)
is_valid = True
# items must be strings, or (lists or dicts) of items
for item in items:
or (isinstance(item, list) and _valid_items(item))
or (isinstance(item, dict) and _valid_
)
if not is_valid:
return is_valid