Fix napalm.junos_rpc get-config filter leaking the __kwarg__ marker (#65867)#69818
Open
ggiesen wants to merge 1 commit into
Open
Fix napalm.junos_rpc get-config filter leaking the __kwarg__ marker (#65867)#69818ggiesen wants to merge 1 commit into
ggiesen wants to merge 1 commit into
Conversation
…altstack#65867) junos.rpc (used by napalm.junos_rpc) builds the RPC ``op`` dict from __pub_arg, which carries the reserved ``__kwarg__`` marker that the Salt CLI appends to keyword arguments. On a ``get-config`` call with a ``filter`` the marker leaked into the RPC options, and junos-eznc's ElementMaker raised ``KeyError: <class 'bool'>`` while rendering the ``True`` value as an XML attribute, so the filter option stopped working after upgrading from 3004. Strip dunder keys from ``op`` with salt.utils.args.clean_kwargs (already used by junos.diff) right after it is assembled, so reserved markers are dropped on every RPC path. Adds regression tests for the get-config and non get-config paths.
Contributor
Author
|
Validated against a live Junos device (junos-eznc 2.8.2, NETCONF over SSH), running the reporter's exact path:
That's the same mechanism the added unit tests cover (only |
twangboy
approved these changes
Jul 17, 2026
Contributor
|
Looks like you have some test failures |
Contributor
Author
|
Thanks @twangboy -- those were the functional zeromq jobs hitting the 6-hour runner timeout on a superseded run, not real failures. The re-run on the same commit is green and the merge state is clean now. |
Contributor
|
It's the most beautiful thing I've ever seen |
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.
What does this PR do?
Fixes
junos.rpc(used bynapalm.junos_rpc) so aget-configcall with afilterworks again.junos.rpcbuilds its RPC options (op) from__pub_arg, which carries the reserved__kwarg__marker that the Salt CLI appends to keyword arguments. That marker leaked into the RPC options; on theget-configpath junos-eznc'sElementMakerthen tried to render theTruevalue as an XML attribute and raisedKeyError: <class 'bool'>, so thefilteroption stopped working after upgrading from 3004 to 3006.The fix strips dunder keys from
opwithsalt.utils.args.clean_kwargs(already used byjunos.diff) right afteropis assembled, so reserved markers are dropped on both theget-configand the generic RPC branch.Fixes
Fixes #65867
Tests
Adds two regression tests in
tests/pytests/unit/modules/test_junos.py:test_rpc_get_config_filter_ignores_kwarg_marker- the reported case:__pub_argcarries{'filter': ..., '__kwarg__': True}and the rendered RPC must be the clean<get-configuration format="xml">...</get-configuration>.test_rpc_non_get_config_ignores_kwarg_marker- the generic path, whereopis forwarded as RPC arguments rather than options.Both fail without the fix (the
get-configcase raisesKeyError: <class 'bool'>in junos-eznc'sElementMaker) and pass with it, verified against real junos-eznc (2.8.2) rendering with onlyDevice.executemocked.Notes
The same
__pub_arghandling block is repeated in several otherjunosfunctions (e.g.cli,commit,install_config). This PR is scoped to the reportedget-configregression; applying the same marker stripping to the other functions can follow separately.