Skip to content

JSON autodetection in cddl::ast::CDDL::validate is a bit iffy #166

@itamarst

Description

@itamarst
  1. This API is not documented as supporting both JSON and CBOR, so I assumed it was just CBOR (https://docs.rs/cddl/latest/cddl/ast/struct.CDDL.html#method.validate). Assuming is bad, but also CBOR is the default for what CDDL does.
  2. A bunch of the logic in there is something I'm going to have reproduce, since I need to only do CBOR and I'm keeping around a CDDL instance.
  3. I discovered this because it guessed wrong on a document because every once in a while the CBOR is valid UTF8, coincidentally.

Perhaps there should be CDDL::validate_cbor() and validate_json()?

I am not sure an auto-guessing method is super-useful, but if it continues to exit the fact it's guessing should be documented, as well as the heuristic it uses.

If you can indicate your preferred next step, I can submit an appropriate PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions