Skip to content

Fix XR indent_adjust misfiring on 'template data timeout' and 'template options timeout' (follow-up to #205)#268

Merged
jtdub merged 1 commit into
netdevops:masterfrom
btarno:fix-xr-template-data-options-timeout
Jul 13, 2026
Merged

Fix XR indent_adjust misfiring on 'template data timeout' and 'template options timeout' (follow-up to #205)#268
jtdub merged 1 commit into
netdevops:masterfrom
btarno:fix-xr-template-data-options-timeout

Conversation

@btarno

@btarno btarno commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Problem

#208 (fixing #205) added a negative lookahead so the XR indent_adjust rule no longer misfires on the bare template timeout <s> leaf inside flow exporter-map ... version v9. However, IOS-XR also renders two sibling leaf forms in the same block:

flow exporter-map EXPORTER1
 version v9
  options interface-table timeout 300
  options sampler-table timeout 300
  template data timeout 15
  template options timeout 15
 !
 transport udp 2055
!
interface Loopback0
 ipv4 address 10.0.0.1 255.255.255.255

template data timeout 15 and template options timeout 15 do not match (?!\s+timeout), so the rule still fires, and since no end-template ever 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, and future(). 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-map version block grammar (template timeout, template data timeout, template options timeout):

^\s*template(?!\s+(?:data\s+|options\s+)?timeout)

Real template <name> ... end-template blocks still match the rule; the existing test_template_block_indent_adjust covers that and still passes.

Testing

  • Added 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 of version v9, and a remediation across the config is unaffected. The parse assertions fail on master and pass with this change.
  • Full suite: 619 passed. ruff check, ruff format --check, and mypy clean on the touched files.
  • Verified against a real ~1900-line IOS-XR 25.2.2 config: tree parses to the correct 249 top-level children and section negation (no interface ...) behaves correctly again.

…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.
@btarno

btarno commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

ready for review

@jtdub

jtdub commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Nice! Thanks Brad! I'll try to give this a look today.

@jtdub jtdub left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jtdub jtdub merged commit 7bf75b1 into netdevops:master Jul 13, 2026
5 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants