Validation results differ on equivalen JSON and CBOR input
chrysn opened this issue · 0 comments
chrysn commented
In an example in which different branches allow different types, validation of an AIU valid data structure succeeds when processing JSON, but fails when processing CBOR.
Inputs
features.json:
{"Foo": {}}
features.cbor:
a1 63 46 6f 6f a0
schema.cddl:
root = group
group = {
? "help" => tstr,
? "features" => feature-set,
* group-label => group,
}
feature-set = {
+ feature-label => feature-help
}
group-label = tstr
feature-label = tstr
feature-help = tstr
Failure mode
Works for JSON:
$ cddl validate --cddl schema.cddl --json features.json
[INFO] Root type for validation: root
[INFO] Validation of "features.json" is successful
Fails for CBOR:
$ cddl validate --cddl schema.cddl --cbor features.cbor
[INFO] Root type for validation: root
[ERROR] Validation of "features.cbor" failed: error validating at cbor location /Map([]): expected object value of type tstr, got object
Further information / context
I'm aware that this is not great CDDL -- it's capturing a particular snapshot of development, and we'll move on to something that's easier to parse as RIOT-OS/RIOT#20366 progresses. Nonetheless, AIU this is a bug in the CDDL implementation (which I'm actually using through pycddl, and thus can't even work around by using JSON for the data that's originally YAML anyway).