printer sid BUGFIX: include nodes augmented into other modules - #2560
Closed
manoe wants to merge 113 commits into
Closed
printer sid BUGFIX: include nodes augmented into other modules#2560manoe wants to merge 113 commits into
manoe wants to merge 113 commits into
Conversation
... with quoted values with both ' and " characters.
... in a single module. Fixes CESNET#2534
Test included.
Required by proper schema-mount data parsing. Fixes sysrepo/sysrepo#3772
Add instructions for installing on Mac OS using homebrew
The CBOR printer kept a single "currently open array" pointer (cborpr_ctx.array) shared across all nesting levels, while tracking the open nodes on a proper stack (cborpr_ctx.open). When a leaf-list or list was nested inside a list, printing the inner array overwrote that pointer and then reset it to NULL, so the enclosing list subsequently pushed into a NULL array, causing a segfault in cbor_array_push(). Replace the single array pointer with a stack (cborpr_ctx.arrays) kept parallel to the open-node stack, add cbor_current_array() to fetch the innermost open array, and update cbor_print_leaf_list()/cbor_print_opaq() and their callers accordingly. The stack is freed on all exit paths of cbor_print_data(). Add a regression test (test_nested_list) covering a leaf-list nested in a list, a list nested in a list, and mixed multi-instance nesting, plus the supporting list-nested node in the cbor-test module. Co-authored-by: Cursor <cursoragent@cursor.com>
The SID generator collected data-namespace items only from the processed module's own compiled tree (lysc_module_dfs_full(module, ...)). Nodes that the module contributes to other modules by augmentation live in the target modules' trees, so they were never collected and got no SID. For models that place feature data via augments (e.g. augmenting a common root module), the generated .sid file ended up with just the module item and no data items. Collect all nodes defined by the processed module wherever they are grafted: after walking the module's own tree, also walk every context module whose augmented_by references the processed module. collect_data_cb now attributes each node to its defining module (node->module), so a foreign module's own nodes are skipped while traversing its tree, and a module's .sid no longer wrongly includes nodes augmented into it by others. Add test_augment covering both directions (the augmenting module's .sid contains the augmented-in node; the base module's .sid does not). Co-authored-by: Cursor <cursoragent@cursor.com>
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.
printer sid BUGFIX: include nodes augmented into other modules
Summary
The RFC 9595 SID generator does not assign SIDs to data nodes that a module
contributes to other modules via
augment. For any module that places itsdata by augmenting another module,
lys_sid_gen()/lys_sid_update()(andyanglint -g) produce a.sidfile containing only themoduleitem and nodata items. This PR makes the generator collect those augmented-in nodes.
Problem
sid_collect_items()gathered data-namespace items only from the processedmodule's own compiled tree:
Nodes that
moduleaugments into another module live in the target module'scompiled tree (their
node->modulestill points back to the augmentingmodule), solysc_module_dfs_full(module, ...)never visits them. As a resultthey receive no SID.
Minimal example — a module whose only data is an augment into another module:
Before this PR,
a1's generated.sidcontains a single item (module a1) and0 data items; the augmented-in
/b1:cont/a1:xis missing.Fix
Collect all nodes defined by the processed module, wherever they are grafted
in the compiled schema:
collect_data_cb()now attributes each node to its defining module and skipsnodes whose
node->modulediffers from the module being processed. This both(a) lets us safely traverse other modules' trees and pick only the
augmented-in nodes, and (b) fixes a latent mis-attribution where a module's own
.sidcould wrongly include nodes augmented into it by others.sid\_collect\_items()also walks everycontext module whose
augmented\_byreferences the processed module (guarded on->compiled), using the same callback.libyang already implements augment target modules when the augmenting module is
implemented (
lys_precompile_augments_deviations()), so the target trees arepresent during generation. The existing choice/case handling and top-level
extension-data (
yang-data/structure) traversal are unchanged.Backward compatibility
Output is unchanged for modules that do not augment other modules. The only
behavioral change is correct attribution: augmented-in nodes now appear in the
augmenting module's
.sid, and are no longer (incorrectly) included in thetarget module's
.sid.Notes
deviated_by) are a separate RFC 9595 concern andare intentionally out of scope here.