Skip to content
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

Validation results differ on equivalen JSON and CBOR input #219

Open
chrysn opened this issue Feb 21, 2024 · 0 comments
Open

Validation results differ on equivalen JSON and CBOR input #219

chrysn opened this issue Feb 21, 2024 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@chrysn
Copy link

chrysn commented Feb 21, 2024

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).

@anweiss anweiss self-assigned this Feb 11, 2025
@anweiss anweiss added the bug Something isn't working label Feb 11, 2025
@anweiss anweiss added this to the v1.0.0 milestone Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants