Fix XR indent_adjust misfiring on 'template data timeout' and 'template options timeout' (follow-up to #205)#268
Merged
jtdub merged 1 commit intoJul 13, 2026
Conversation
…te options timeout' (follow-up to netdevops#205) The negative lookahead added in netdevops#208 excludes only the bare 'template timeout' leaf form. IOS-XR flow exporter-map version blocks also use 'template data timeout <s>' and 'template options timeout <s>', which still matched the indent_adjust start expression. With no 'end-template' ever arriving, every line after the flow exporter-map was nested under the timeout leaf, silently corrupting the tree for the rest of the config (negations and merges against top-level sections stop matching). Extend the lookahead to cover all three leaf forms: ^\s*template(?!\s+(?:data\s+|options\s+)?timeout) Real 'template <name> ... end-template' blocks are unaffected.
Contributor
Author
|
ready for review |
Contributor
|
Nice! Thanks Brad! I'll try to give this a look today. |
jtdub
added a commit
that referenced
this pull request
Jul 13, 2026
Bump version to 3.6.2 and finalize CHANGELOG: - Add [3.6.2] - 2026-07-13 heading with the #268 fix (XR indent_adjust misfiring on 'template data timeout' / 'template options timeout') Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
#208 (fixing #205) added a negative lookahead so the XR
indent_adjustrule no longer misfires on the baretemplate timeout <s>leaf insideflow exporter-map ... version v9. However, IOS-XR also renders two sibling leaf forms in the same block:template data timeout 15andtemplate options timeout 15do not match(?!\s+timeout), so the rule still fires, and since noend-templateever arrives, every subsequent line of the config is nested under the timeout leaf. On a real production IOS-XR config (Cisco 8000, ~1900 lines) the tree collapses from 249 top-level children to 110, and everything after the flow exporter-map (interfaces, router bgp, router isis, ...) silently stops matching for negations, merges,config_to_get_to, andfuture(). Any XR config that exports NetFlow/IPFIX with explicit template timeouts hits this.Fix
Extend the lookahead to cover all three leaf forms from the
flow exporter-mapversion block grammar (template timeout,template data timeout,template options timeout):Real
template <name> ... end-templateblocks still match the rule; the existingtest_template_block_indent_adjustcovers that and still passes.Testing
test_flow_exporter_template_data_options_timeout_indent_adjust, modeled on the Update the XR driver per github issues #205 and #206 #208 test: asserts the sections following the exporter-map stay at the top level, the timeout leaves parse as children ofversion v9, and a remediation across the config is unaffected. The parse assertions fail on master and pass with this change.ruff check,ruff format --check, andmypyclean on the touched files.no interface ...) behaves correctly again.