Skip to content

Fix inline template_source crash and ignored commit_at in napalm_network#69795

Open
ggiesen wants to merge 3 commits into
saltstack:3006.xfrom
ggiesen:fix-napalm-network-core
Open

Fix inline template_source crash and ignored commit_at in napalm_network#69795
ggiesen wants to merge 3 commits into
saltstack:3006.xfrom
ggiesen:fix-napalm-network-core

Conversation

@ggiesen

@ggiesen ggiesen commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes two bugs in napalm_network, the module every NAPALM set_*/delete_*
and net.load_config/net.load_template call flows through.

  1. load_template crashes when rendering an inline template_source. The
    salt:///file precheck runs template_name.startswith(...), but
    template_name is None when only template_source is given, so it raised
    AttributeError: 'NoneType' object has no attribute 'startswith' -- the
    documented inline usage (net.load_template template_source='...') was
    unusable. The precheck now runs only for a single, named (string)
    template_name; None (inline source) and lists are handled elsewhere.

  2. _config_logic ignores commit_at. When scheduling a commit it called
    get_time_at(time_in=commit_in, time_at=commit_in) -- commit_at was passed
    as commit_in, so committing at an absolute time (commit_at=...) was
    silently ignored (the revert path already used the correct
    time_at=revert_at). Fixed to time_at=commit_at.

What issues does this PR fix or reference?

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

Merge requirements satisfied?

  • Docs
  • Changelog
  • Tests written/updated

Added to tests/pytests/unit/modules/napalm/test_network.py:
test_load_template_inline_source (inline template_source with no
template_name renders instead of crashing) and
test_load_config_commit_at_uses_absolute_time (asserts get_time_at receives
time_at=commit_at, time_in=None). Both fail against the current code.

Commits signed with GPG?

No

- load_template ran the salt://-prefix precheck as template_name.startswith(...)
  even when template_name is None (rendering an inline template_source),
  crashing with AttributeError. Run that precheck only for a single string
  template_name; None (inline source) and lists are handled separately.

- _config_logic scheduled a commit with get_time_at(time_in=commit_in,
  time_at=commit_in), so commit_at (commit at an absolute time) was ignored.
  Pass time_at=commit_at, matching the revert path.
@ggiesen ggiesen requested a review from a team as a code owner July 12, 2026 03:42
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