You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for the thorough report @ScriptToddler ! I haven't reviewed the code changes, but the output for your example inputs definitely highlights the issue. We can review the code change if you want to open a PR.
Hi @jszwedko,
As suggested I opened a PR (#849) with my proposal, but then again not sure if it is the best way to fix the issue (but it does work for me with no regression seen thus far)
Hello,
Problem
There appears to be an inconsistency with
text_key
inparse_xml
functionWhenever a chain of an "even" number of single child is present, the text key seems to be forcibly added even when it should not.
E.g. :
<root><a>test</a></root>
results in{ "root": { "a": { "text": "test" } } }
instead of expected{ "root": { "a": "test" } }
https://playground.vrl.dev/?state=eyJwcm9ncmFtIjoiLnhtbF9wYXJzZWQgPSBwYXJzZV94bWwhKC5tZXNzYWdlKSIsImV2ZW50Ijp7Im1lc3NhZ2UiOiI8cm9vdD48YT50ZXN0PC9hPjwvcm9vdD4ifSwiaXNfanNvbmwiOmZhbHNlLCJlcnJvciI6bnVsbH0%3D
<root><a><a1>test</a1></a></root>
results in expected{ "root": { "a": { "a1": "test" } } }
https://playground.vrl.dev/?state=eyJwcm9ncmFtIjoiLnhtbF9wYXJzZWQgPSBwYXJzZV94bWwhKC5tZXNzYWdlKSIsImV2ZW50Ijp7Im1lc3NhZ2UiOiI8cm9vdD48YT48YTE%2BdGVzdDwvYTE%2BPC9hPjwvcm9vdD4ifSwiaXNfanNvbmwiOmZhbHNlLCJlcnJvciI6bnVsbH0%3D
<root><a><a1><a2>test</a2></a1></a></root>
results in{ "root": { "a": { "a1": { "a2": { "text": "test" } } } } }
instead of expected{ "root": { "a": { "a1": { "a2": "test" } } } }
https://playground.vrl.dev/?state=eyJwcm9ncmFtIjoiLnhtbF9wYXJzZWQgPSBwYXJzZV94bWwhKC5tZXNzYWdlKSIsImV2ZW50Ijp7Im1lc3NhZ2UiOiI8cm9vdD48YT48YTE%2BPGEyPnRlc3Q8L2EyPjwvYTE%2BPC9hPjwvcm9vdD4ifSwiaXNfanNvbmwiOmZhbHNlLCJlcnJvciI6bnVsbH0%3D
<a>
node, the<a1>
node then is nested with a text keyhttps://playground.vrl.dev/?state=eyJwcm9ncmFtIjoiLnhtbF9wYXJzZWQgPSBwYXJzZV94bWwhKC5tZXNzYWdlKSIsImV2ZW50Ijp7Im1lc3NhZ2UiOiI8cm9vdD48YT48YTE%2BdGVzdDwvYTE%2BPC9hPjxiPmZvbzwvYj48L3Jvb3Q%2BIn0sImlzX2pzb25sIjpmYWxzZSwiZXJyb3IiOm51bGx9
Investigation (might be mistaken)
I tried to investigate the issue and it seems to me the problem stems from the recurse implementation with single nodes, and precisely this line
vrl/src/stdlib/parse_xml.rs
Line 356 in e58ac80
When recursing the value of the node which would then incorrectly add the text key later on at this step (if I am not mistaken) :
vrl/src/stdlib/parse_xml.rs
Line 296 in e58ac80
The problem seems to be fixed on my end if instead of the recurse, the process_node function is instead called on the node, with no regression seen so far.
I have proposed such a fix on a branch on my forked version of the project there https://github.com/vectordotdev/vrl/compare/main...ScriptToddler:vrl:fix/parse_xml_unique_child_text?expand=1 along with tests highlighting the issue.
I may be mistaken, in which case you may just discard what I said in this last part
Thank you,
The text was updated successfully, but these errors were encountered: