Subject: [Cbor] Invalid Tag Values

From: Kio Smallwood <[email-masked]>
Date: Thu, 24 Jun 2021 20:15:16 +0100

Hi All, 

I'm having trouble understanding the rationale of intentionally invalid
tags as documented here[1] 

Under what circumstances would an encoder produce these tags and what
should a decoder do when encountering them? Since I'm working on that
part of the decoder[2] anyway I thought I'd better check. 

Thanks, 

Kio 

[1]
https://www.ietf.org/archive/id/draft-bormann-cbor-notable-tags-03.html#section-toc.1-1.10.2.1.1

[2] https://github.com/agronholm/cbor2/pull/115

---

From: Laurence Lundblade <[email-masked]>
Date: Thu, 24 Jun 2021 12:20:03 -0700

My understanding and use of them is this — they are never put in encoded CBOR and they are useful *inside* a decoder to have an out-of-band value tag like a NULL pointer.

LL

> On Jun 24, 2021, at 12:15 PM, Kio Smallwood <[email-masked]> wrote:
> 
> Hi All,
> 
> I'm having trouble understanding the rationale of intentionally invalid tags as documented here[1]
> 
> Under what circumstances would an encoder produce these tags and what should a decoder do when encountering them? Since I'm working on that part of the decoder[2] anyway I thought I'd better check.
> 
> Thanks,
> 
> Kio
> 
> [1] https://www.ietf.org/archive/id/draft-bormann-cbor-notable-tags-03.html#section-toc.1-1.10.2.1.1 <https://www.ietf.org/archive/id/draft-bormann-cbor-notable-tags-03.html#section-toc.1-1.10.2.1.1>
> [2] https://github.com/agronholm/cbor2/pull/115 <https://github.com/agronholm/cbor2/pull/115>_______________________________________________
> CBOR mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/cbor

---

From: Carsten Bormann <[email-masked]>
Date: Thu, 24 Jun 2021 21:21:40 +0200

Hi Kio,

> Under what circumstances would an encoder produce these tags

Never.  They are explicitly reserved so that an implementation has a selection of tag numbers that it can use internally, such as in order to mark the absence of a tag.

> and what should a decoder do when encountering them?

Mark the data item as invalid.
I don’t think a more rigorous response (rejecting the data item the same way that a non-well-formed input would be) would be out of line, as the tag numbers are explicitly marked as “not to occur in interchange”.
(RFC 8949 just doesn’t have a category between non-well-formed and invalid that we could use here.)

> Since I'm working on that part of the decoder[2] anyway I thought I'd better check.

Thank you a lot for doing this!

If you have suggestions how the text in -notable-tags could be made even more explicit about this, please tell us.

Grüße, Carsten

---

From: Kio Smallwood <[email-masked]>
Date: Thu, 24 Jun 2021 21:11:54 +0100

Hi Carsten, 

So if I follow the logic correctly, if my decoder encounters
0("1900-01-00T00:00;00") instead of raising an exception it could return

65535({
    "value": "1900-01-00T00:00;00", 
    "_error":"invalid datetime string: '1900-01-00T00:00;00'",
    "original_tag": 0
})

to the application? We could then have a tag handler or schema verifier
raise the error or just log it, but in this case the full CBOR stream
would be decoded. 

Thanks, 

Kio 

On 2021-06-24 20:21, Carsten Bormann wrote:

> I don't think a more rigorous response (rejecting the data item the same way that a non-well-formed input would be) would be out of line, as the tag numbers are explicitly marked as "not to occur in interchange".
> (RFC 8949 just doesn't have a category between non-well-formed and invalid that we could use here.)
> 
> _______________________________________________
> CBOR mailing list
> [email-masked]

---

From: Carsten Bormann <[email-masked]>
Date: Thu, 24 Jun 2021 22:15:45 +0200

On 2021-06-24, at 22:11, Kio Smallwood <[email-masked]> wrote:
> 
> So if I follow the logic correctly, if my decoder encounters 0("1900-01-00T00:00;00") instead of raising an exception it could return
> 
> 65535({
> to the application? We could then have a tag handler or schema verifier raise the error or just log it, but in this case the full CBOR stream would be decoded.

If you don’t have a way to funnel up an error indication completely separate from the tag system, this strikes me as the second best way to do it.

Grüße, Carsten