Fix inline template_source crash and ignored commit_at in napalm_network#69795
Open
ggiesen wants to merge 3 commits into
Open
Fix inline template_source crash and ignored commit_at in napalm_network#69795ggiesen wants to merge 3 commits into
ggiesen wants to merge 3 commits into
Conversation
- 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.
This was referenced Jul 12, 2026
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 two bugs in
napalm_network, the module every NAPALMset_*/delete_*and
net.load_config/net.load_templatecall flows through.load_templatecrashes when rendering an inlinetemplate_source. Thesalt:///fileprecheck runstemplate_name.startswith(...), buttemplate_nameisNonewhen onlytemplate_sourceis given, so it raisedAttributeError: 'NoneType' object has no attribute 'startswith'-- thedocumented inline usage (
net.load_template template_source='...') wasunusable. The precheck now runs only for a single, named (string)
template_name;None(inline source) and lists are handled elsewhere._config_logicignorescommit_at. When scheduling a commit it calledget_time_at(time_in=commit_in, time_at=commit_in)--commit_atwas passedas
commit_in, so committing at an absolute time (commit_at=...) wassilently ignored (the revert path already used the correct
time_at=revert_at). Fixed totime_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?
Added to
tests/pytests/unit/modules/napalm/test_network.py:test_load_template_inline_source(inlinetemplate_sourcewith notemplate_namerenders instead of crashing) andtest_load_config_commit_at_uses_absolute_time(assertsget_time_atreceivestime_at=commit_at,time_in=None). Both fail against the current code.Commits signed with GPG?
No