SelectSingleNode('', XmlNode) crashes BC
Calling SelectSingleNode with a variable type text, which is empty, crashes BC.
Sample code: if XmlDoc.GetRoot(xmlRoot) then if xmlRoot.SelectSingleNode(xpath, XmlN) then begin <- crash line xpathvalue := XmlN.AsXmlElement().InnerXml(); exit(true); end;
ClientSessionId: ced62ee5-3bfe-4113-86a4-8d1fd2a19532 ClientActivityId: 9a8715ef-925d-40ee-9a8c-2babb25cf3ef ServerSessionUniqueId: 962acabb-3f3e-4839-9125-1dfdb6b7b5b4 ServerActivityId: a4e18470-6443-4977-8051-c2ebfba69db1 EventTime: 02/13/2019 14:29:53 Message (XPathException): This message had personal data removed. The original may still be in transient telemetry. Find it using the transientTelemetryId. ParentException: XPathException Expression must evaluate to a node-set. ExceptionStackTrace: at Microsoft.Dynamics.Nav.Runtime.NavApplicationMethod.InvokeMethod(ITreeObject obj, String methodName, Object[] args, Boolean resolveHandler, Boolean throwOnNotFound) at Microsoft.Dynamics.Nav.Runtime.NavForm.RaiseOnAction(Nullable`1 actionId, String actionTriggerMethodName) at Microsoft.Dynamics.Nav.Service.NSField.ActionField(NavSession con) at Microsoft.Dynamics.Nav.Service.NSField.Action(NavSession session) at SyncInvokeActionField(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.RunInTransactionCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, MethodBase syncMethod, Object[] inputs, Object[]& outputs)
Hi @thpeder, is someone already looking into this?
BC also crashes if a variable is not empty, but the Node cannot be found (probably the same outcome). I also added [TryFunction] to the function, but it makes no difference.
@angela2389 @extensionsv2training we will try to fix it for the next major release. Could you please help us to fix it faster by providing a self-contained extension + input data so that we can reproduce the issue?
Hi Alexandru,
I tried to reproduce in a small extension, but now get (for the first time): "The XPath query "/ blabla" does not match one of the nodes.".
I also tried in the original codeunit, but it doesn't crash there either anymore.
Actually, it seems with Xml that if you "incorrectly" use it, it crashes BC occasionally. It can go 10 times good and then 10 times bad.
Thanks @angela2389! I'll mark this as a bug. It looks like we need to add better error handling to the API.
Hi,
Many thanks for raising this issue. Unfortunately we have not been able to get to this issue as soon as we'd have liked. Since it has been a long time since this issue was last updated, it is possible that this has been fixed by a newer release of Business Central and the AL extension for Visual Studio Code. We have thus decided to close it.
If the issue still affects you on the latest insider build of Business Central, please help us and open a new issue for us with the latest steps to reproduce the issue, and link back to this closed issue to track any comments or discussions.
Thanks,
Thaddeus