Skip to content

Fix napalm_rpc_map override, netmiko error, and napalm_formula arg bugs#69797

Open
ggiesen wants to merge 2 commits into
saltstack:3006.xfrom
ggiesen:fix-napalm-mod-formula
Open

Fix napalm_rpc_map override, netmiko error, and napalm_formula arg bugs#69797
ggiesen wants to merge 2 commits into
saltstack:3006.xfrom
ggiesen:fix-napalm-mod-formula

Conversation

@ggiesen

@ggiesen ggiesen commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes four bugs in the napalm_mod and napalm_formula execution modules.

napalm_mod:

  1. rpc ignores the user's napalm_rpc_map. It did
    napalm_map = config.get("napalm_rpc_map", {}) then
    napalm_map.update(default_map), so the built-in defaults clobbered the
    user's override (and, since config.get can return a live reference, the
    defaults were written back into the user's pillar). An operator setting
    napalm_rpc_map: {junos: napalm.netmiko_commands} to force CLI RPC on a Junos
    box had it silently ignored. Now the defaults are the base and the user map is
    layered on top, without mutating the config object.
  2. netmiko_args raises a raw KeyError when the NAPALM os grain isn't in
    the (built-in + user) netmiko_device_type_map -- e.g. a community/custom
    driver with no mapping. Now it raises a clear CommandExecutionError naming
    the driver and pointing at netmiko_device_type_map.

napalm_formula:
3. container_path drops its key/container/delim arguments -- it called
_container_path(model) with defaults, so container_path(model, delim='//')
(the documented way to avoid : clashing with IPv6 addresses / Junos QFX
interface names) was silently ignored. Now they're passed through.
4. render_field reads __grains__['os'] unguarded, raising KeyError when
the os grain isn't populated. Now __grains__.get('os').

What issues does this PR fix or reference?

Found by an audit of the NAPALM modules (same series as #69793 / #69794 /
#69795 / #69796).

Merge requirements satisfied?

  • Docs
  • Changelog
  • Tests written/updated

test_rpc_user_map_overrides_default, test_netmiko_args_unknown_os_raises_clean_error
(in test_mod.py), test_container_path_uses_delim, test_render_field_no_os_grain
(in test_formula.py). All fail against the current code.

Commits signed with GPG?

No

ggiesen added 2 commits July 12, 2026 00:10
napalm_mod:
- rpc: napalm_map = config.get(...); napalm_map.update(default_map) let the
  built-in defaults clobber the user's napalm_rpc_map override (and mutated the
  config object). Start from the defaults and layer the user map on top.
- netmiko_args: netmiko_device_type_map[__grains__["os"]] raised a raw KeyError
  for an os not in the map (community/custom drivers). Raise a clear
  CommandExecutionError naming the driver and the config option instead.

napalm_formula:
- container_path ignored its key/container/delim arguments (called
  _container_path(model) with defaults), so e.g. delim='//' was silently
  dropped. Forward them.
- render_field read __grains__["os"] directly, raising KeyError when the os
  grain is absent. Use __grains__.get("os").
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants