lib: northbound: distinguish unknown schema node from key mismatch - #21534
Conversation
Greptile SummaryThis PR improves Confidence Score: 5/5Safe to merge β error-path-only change with no impact on the happy path, return codes, or ABI. No P0 or P1 findings. The change is narrowly scoped to an existing error branch, No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["nb_candidate_edit_tree_add()"] --> B{"root || !REPLACE && !MODIFY?"}
B -- Yes --> C[Skip key check]
B -- No --> D["lyd_find_path(tree, xpath)"]
D -- Success --> E[Continue normal path]
D -- Failure --> F["lys_find_path(ly_native_ctx, NULL, xpath)"]
F -- NULL\nschema node not found --> G["errmsg: 'Unknown schema node in xpath: <xpath>'\nret = NB_ERR\ngoto done"]
F -- non-NULL\nschema node exists --> H["errmsg: 'List keys in xpath and data tree are different'\nret = NB_ERR\ngoto done"]
Reviews (2): Last reviewed commit: "lib: northbound: distinguish unknown sch..." | Re-trigger Greptile |
|
Additional validation β re-ran the two probes inside a real FRR deployment (podman-in-podman chassis, image Probes via
Schema typo detected distinctly; key-mismatch message preserved verbatim (matching the existing assertion at |
5250eaf to
329009b
Compare
|
Full validation suite for the amended commit (adds the new topotest case). T1 β Existing topotest suite passesT2 β New test case for the new branchAdded in T3 β Chassis-real validationAlready included in the earlier comment: patched T4 β Multiple entry points
T5 β No regression under loadRan Happy-path unaffected as expected β the extra |
|
Raw artifact (chassis probes + sha256 attestations) preserved as gist for reproducibility: https://gist.github.com/reinaldosaraiva/33b4a402eb6dccbd4e4dee450600ebb7 |
|
Thanks @greptile-apps β good catch on the Edit-config xpaths are constrained to canonical instance-identifiers.
None of these can legally carry
If a future change relaxes the edit-config xpath contract (e.g. to permit XPath predicates), this site should adopt the fallback then. Happy to add an inline comment noting this constraint if a maintainer prefers. |
|
That reasoning is sound. The distinction you've drawn β that The inline comment would be a good addition. Something like: That documents the constraint so future readers don't second-guess the choice or inadvertently "fix" it. |
329009b to
ec981fd
Compare
|
Thanks @greptile-apps β applied the inline comment verbatim. Force-pushed as The extended comment now documents both what the schema-only lookup distinguishes and why
|
When an mgmt edit-config arrives with an xpath that cannot be resolved
against the data tree, lyd_find_path returns an error and mgmtd emits
"List keys in xpath and data tree are different" for two distinct
failure modes:
- the xpath names a schema node that does not exist (typo, e.g.
"prefix-lst" instead of "prefix-list"); and
- the xpath resolves to a valid schema node, but the key predicates
do not match the keys carried in the payload.
The combined message makes the first case hard to debug -- operators
and external controllers cannot tell the schema name is wrong without
cross-referencing the YANG tree by hand.
Call lys_find_path() against the schema context on the error path: if
the xpath does not resolve to any schema node, emit "Unknown schema
node in xpath: <xpath>"; otherwise keep the existing message. The
extra lookup runs only when lyd_find_path has already failed, so the
happy path is unaffected.
Empirically verified on mgmtd 10.6 with two probes -- xpath with a
typoed node name (prefix-lst) and xpath with a mismatched key -- which
previously returned the same message and now return distinct ones.
Signed-off-by: Reinaldo Saraiva <reinaldo.saraiva@gmail.com>
ec981fd to
7c4498d
Compare
|
Proactively applied the frrbot style diff β force-pushed as |
Summary
mgmtdcurrently emits"List keys in xpath and data tree are different"for two distinctedit-configfailure modes:interfacinstead ofinterface); andThe combined message makes the first case hard to debug β operators and external controllers cannot tell the schema name is wrong without cross-referencing the YANG tree by hand.
This patch calls
lys_find_path()on the schema context only on the error path: if the xpath does not resolve to any schema node, emit"Unknown schema node in xpath: <xpath>"; otherwise keep the existing message. Happy path is unaffected.Test plan
tools/checkpatch.pl --no-tree -g HEADβ 0 errors, 0 warningstests/topotests/mgmt_tests/test_yang_mgmt.py:500still passes β it asserts the key-mismatch message which is preserved verbatimmgmt edit replace /frr-interface:lib/interfac[name='eth0'] ...β% Unknown schema node in xpath: /frr-interface:lib/interfac[name='eth0']mgmt edit replace /frr-interface:lib/interface[name='eth0'] ...(payload withname='eth1') β% List keys in xpath and data tree are differentWhy this is safe
NB_ERR) is unchanged.lys_find_pathruns exclusively whenlyd_find_pathalready failed.