Subject: [Cbor] Conflicting tags

From: Laurence Lundblade <[email-masked]>
Date: Thu, 7 May 2020 11:46:14 -0700

I am after comments and wisdom on what to do when encountering a data item with conflicting tags, say one that is tagged both a positive and negative bignum (both byte strings), or one that is tagged as both a CWT and a decimal fraction (both arrays).

Just passing the tag up to the next layer can’t be the answer because that is just passing the error condition along, not detecting it. I think it needs to be detected and handled.

The context for my question is a generic decoder that does full decoding of many of the tags itself rather than just passing a tag indicator up. For example, C supports arrays of integers natively, so it would be good for a generic decoder to decode some RFC 8746 tags to a C array of integers.

It seems reasonable to detect conflicts for the tags that are known and handled. Maybe a little messy, but possible, even for dozens of them or even for most of the registered tags.  The question is what to do about unknown tags.

My thought is the the implementation considers some of the known tags to be hints and others to be new type definitions. The hint tags are usually the ones for suggested conversions. 

The apply the following:
- Data item with only unknown tags: pass all the tags up
- Data item with known data type tag that will be fully decoded, plus an unknown tag: this is an error
- Data item with with hint tags that are being passed up and unknown tags: pass all the tags up

Thanks for thoughts and comments!

LL

---

From: Carsten Bormann <[email-masked]>
Date: Thu, 7 May 2020 20:55:28 +0200

> I am after comments and wisdom on what to do when encountering a data item with conflicting tags, say one that is tagged both a positive and negative bignum (both byte strings), or one that is tagg…

Cannot happen, I’d say.
The outer tag is tagging the inner tag.
But Tag 2 and Tag 3 are both defined only for byte strings, so the outer tag has a wrong type as its value.

Grüße, Carsten