Skip to content

fix(netconf-proto): handle empty containers in copy_buffer_till functions - #28

Open
riccardo-negri wants to merge 1 commit into
network-analytics:mainfrom
riccardo-negri:fix-netconf
Open

fix(netconf-proto): handle empty containers in copy_buffer_till functions#28
riccardo-negri wants to merge 1 commit into
network-analytics:mainfrom
riccardo-negri:fix-netconf

Conversation

@riccardo-negri

@riccardo-negri riccardo-negri commented Aug 5, 2026

Copy link
Copy Markdown
Member

A <get> reply whose filter matched nothing comes back as a
self-closing <data/> (e.g. IOS-XR when a queried dynamic subscription
is absent from the operational datastore). copy_buffer_till then found
no </data> end tag to copy up to and scanned to EOF, surfacing the
misleading SSH codec error NETCONF XML parsing error: 'Found EOF while expecting data' and failing the YANG Library fetch.

The same latent defect existed at every copy_buffer_till /
copy_buffer_till_with_namespaces call site (empty subtree filter,
<config/>, <rpc/>, <rpc-reply/>, ...): none guarded against an
empty or self-closing container. Guard both primitives with
parent_has_child() -- mirroring collect_xml_sequence* -- so all seven
call sites return empty content instead of running to EOF.

Add unit tests for the two primitives and an end-to-end rpc-reply test
covering both the <data/> and <data></data> forms.

@riccardo-negri riccardo-negri self-assigned this Aug 5, 2026
@riccardo-negri
riccardo-negri force-pushed the fix-netconf branch 3 times, most recently from debf069 to b9632a8 Compare August 5, 2026 09:35
@riccardo-negri riccardo-negri changed the title fix(netconf-proto): parse empty <data/> replies without EOF error fix(netconf-proto): handle empty containers in copy_buffer_till functions Aug 5, 2026
@rodonile
rodonile requested a lite review from Copilot August 5, 2026 09:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes NETCONF XML subtree copying so self-closing/empty containers (e.g. <data/> or <data></data>) no longer cause copy_buffer_till* to scan to EOF and surface misleading parsing errors, restoring correct behavior for empty <get> / <get-config> replies.

Changes:

  • Add a parent_has_child() guard to copy_buffer_till and copy_buffer_till_with_namespaces to return empty content for empty/self-closing containers.
  • Add unit tests covering empty/self-closing containers for both primitives.
  • Add an end-to-end RpcReply test ensuring <data/> and <data></data> parse as empty data.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
crates/netconf-proto/src/xml_utils.rs Guards the copy primitives against empty/self-closing containers and adds targeted unit tests.
crates/netconf-proto/src/protocol.rs Adds an end-to-end RPC reply test for empty <data> forms.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/netconf-proto/src/xml_utils.rs
ustorbeck
ustorbeck previously approved these changes Aug 5, 2026
A `<get>` reply whose filter matched nothing comes back as a
self-closing `<data/>` (e.g. IOS-XR when a queried dynamic subscription
is absent from the operational datastore). `copy_buffer_till` then found
no `</data>` end tag to copy up to and scanned to EOF, surfacing the
misleading `SSH codec error NETCONF XML parsing error: 'Found EOF while
expecting data'` and failing the YANG Library fetch.

The same latent defect existed at every copy_buffer_till /
copy_buffer_till_with_namespaces call site (empty subtree filter,
`<config/>`, `<rpc/>`, `<rpc-reply/>`, ...): none guarded against an
empty or self-closing container. Guard both primitives with
parent_has_child() -- mirroring collect_xml_sequence* -- so all seven
call sites return empty content instead of running to EOF.

Add unit tests for the two primitives and an end-to-end rpc-reply test
covering both the `<data/>` and `<data></data>` forms.
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.

4 participants