Repository navigation
parser cbor FEATURE RESTCONF notification envelope - #2616
Merged
Merged
Conversation
The CBOR format is built only when libcbor is found, but this was recorded in the private ENABLE_CBOR_SUPPORT definition, so an application had no way to tell whether LYD_CBOR works. Replace the private definition with LY_HAVE_CBOR in the installed ly_config.h so that both libyang and its users test the same macro.
lyd_parse_op() accepted only JSON for LYD_TYPE_NOTIF_RESTCONF, so a CBOR-encoded notification (RFC 8040 envelope in RFC 9254 encoding, as sent by UDP-Notif) could not be parsed with its eventTime. The CBOR input is decoded as a whole, so the envelope is checked directly in the loaded map and eventTime is created in the envelope wherever it is placed, unlike the streaming JSON parser. Also cover a notification nested in a list and one with an anydata payload in the CBOR round-trip tests.
LYD_TYPE_RPC_RESTCONF and LYD_TYPE_REPLY_RESTCONF did not check the format, so LYB or CBOR input was passed to the JSON RESTCONF parser. Only XML and JSON are documented and supported, reject the rest.
lydcbor_item_to_string() read only definite-length strings, an indefinite-length (chunked) text or byte string, valid per RFC 8949, was read as an empty string. Concatenate its chunks.
michalvasko
approved these changes
Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds CBOR support for RESTCONF notifications, which sysrepo needs to parse CBOR-encoded UDP-Notif messages.
It contains 4 changes:
lyd_parse_op()withLYD_TYPE_NOTIF_RESTCONFacceptsLYD_CBOR,LY_HAVE_CBORmacro inly_config.h, defined when libyang is built with libcbor, so applications can tell whetherLYD_CBORworks,LYD_TYPE_RPC_RESTCONFandLYD_TYPE_REPLY_RESTCONFreject formats other than XML and JSON instead of passing them to the JSON parser,