Azure / LogicAppsUX

https://learn.microsoft.com/azure/logic-apps
MIT License
74 stars 80 forks source link

Exception while generating XSLT when using custom functions from different files #4347

Open chris-w-dev opened 6 months ago

chris-w-dev commented 6 months ago

Describe the Bug with repro steps

When you use multiple custom functions in a map definition and each custom function is defined in its own XML file in folder Artifacts\DataMapper\Extensions\Functions, the XSLT generation throws the below exception.

Both functions show up just fine in the designer, even after reopening the map:

functions-in-multiple-xml-files

Exception details:

Error message: correlationId='de2d5a40-829a-4f68-ab78-2ac881d8d81f', operationName='DataMapper.XsltCompiler.WriteCustomInlineFunctionsAsync', message='Error in processing custom functions definition from '<removed>\Artifacts\DataMapper\Extensions\Functions\function2.xml'.', exception='System.Xml.XmlException: 'name' is a duplicate attribute name.
   at System.Xml.XmlWellFormedWriter.AddAttribute(String prefix, String localName, String namespaceName)
   at System.Xml.XmlWellFormedWriter.WriteStartAttribute(String prefix, String localName, String namespaceName)
   at Microsoft.Azure.Workflows.DataMapper.XsltCompiler.XslWriter.<>c__DisplayClass22_1.<WriteCustomInlineFunctionsAsync>b__2()', organizationId='', activityVector='IN.00', additionalProperties='{"ParentActivityId":"00-546dac1270d4b49905b16365e0059627-90a7ed06151b8c7d-00"}', extensionVersion='1.58.21.0', siteName='UNDEFINED_SITE_NAME', slotName='', activityId='de2d5a40-829a-4f68-ab78-2ac881d8d81f'.
Error message: correlationId='de2d5a40-829a-4f68-ab78-2ac881d8d81f', operationName='ErrorResponseHandling.GetErrorResponseMessage.POST/RUNTIME/WORKFLOW/MANAGEMENT/', message='Http request failed with unhandled exception of type 'InvalidOperationException' and message: 'System.InvalidOperationException: The Writer is closed or in error state.
   at System.Xml.XmlWellFormedWriter.AdvanceState(Token token)
   at System.Xml.XmlWellFormedWriter.WriteEndElement()
   at Microsoft.Azure.Workflows.DataMapper.XsltCompiler.XslWriter.WriteEndElement()
   at Microsoft.Azure.Workflows.DataMapper.XsltCompiler.XslWriter.WriteFooter()
   at Microsoft.Azure.Workflows.DataMapper.XsltCompiler.MapXsltGenerator.GenerateAsync()
   at Microsoft.Azure.Workflows.Data.Utilities.DataMapper.DataMapperUtility.GenerateXslt(FlowConfiguration flowConfiguration, String mapContent, CancellationToken cancellationToken)
   at Microsoft.Azure.Workflows.Web.Controllers.EdgeMapDesignerApiController.GenerateXslt(CancellationToken cancellationToken)
   at Microsoft.Azure.Workflows.Web.BaseFlowExtensionRouteInitializer.Invoke(HttpRequestMessage request, CancellationToken cancellationToken)
   at Microsoft.Azure.Workflows.Web.Handlers.FlowExtensionHttpRequestHandler.HandleRequest(HttpRequestMessage request, CancellationToken cancellationToken)
   at Microsoft.Azure.Workflows.Web.Handlers.FlowExtensionAuthorizationHandler.HandleRequest(HttpRequestMessage request, CancellationToken cancellationToken)
   at Microsoft.Azure.Workflows.Web.Handlers.FlowExtensionErrorResponseHandler.HandleRequest(HttpRequestMessage request, CancellationToken cancellationToken)'.', exception='System.InvalidOperationException: The Writer is closed or in error state.
   at System.Xml.XmlWellFormedWriter.AdvanceState(Token token)
   at System.Xml.XmlWellFormedWriter.WriteEndElement()
   at Microsoft.Azure.Workflows.DataMapper.XsltCompiler.XslWriter.WriteEndElement()
   at Microsoft.Azure.Workflows.DataMapper.XsltCompiler.XslWriter.WriteFooter()
   at Microsoft.Azure.Workflows.DataMapper.XsltCompiler.MapXsltGenerator.GenerateAsync()
   at Microsoft.Azure.Workflows.Data.Utilities.DataMapper.DataMapperUtility.GenerateXslt(FlowConfiguration flowConfiguration, String mapContent, CancellationToken cancellationToken)
   at Microsoft.Azure.Workflows.Web.Controllers.EdgeMapDesignerApiController.GenerateXslt(CancellationToken cancellationToken)
   at Microsoft.Azure.Workflows.Web.BaseFlowExtensionRouteInitializer.Invoke(HttpRequestMessage request, CancellationToken cancellationToken)
   at Microsoft.Azure.Workflows.Web.Handlers.FlowExtensionHttpRequestHandler.HandleRequest(HttpRequestMessage request, CancellationToken cancellationToken)
   at Microsoft.Azure.Workflows.Web.Handlers.FlowExtensionAuthorizationHandler.HandleRequest(HttpRequestMessage request, CancellationToken cancellationToken)
   at Microsoft.Azure.Workflows.Web.Handlers.FlowExtensionErrorResponseHandler.HandleRequest(HttpRequestMessage request, CancellationToken cancellationToken)', organizationId='', activityVector='IN.00', additionalProperties='{"ParentActivityId":"00-546dac1270d4b49905b16365e0059627-90a7ed06151b8c7d-00"}', extensionVersion='1.58.21.0', siteName='UNDEFINED_SITE_NAME', slotName='', activityId='de2d5a40-829a-4f68-ab78-2ac881d8d81f'.

Map definition:

$version: 1
$input: JSON
$output: JSON
$sourceSchema: schema.json
$targetSchema: schema.json
root:
  OrderNo: function1(/root/OrderNo)
  salesOrg: function2(/root/salesOrg)

Schema:

{
    "type": "object",
    "properties": {
        "OrderNo": {
            "type": "string"
        },
        "salesOrg": {
            "type": "string"
        }
    }
}

function1.xml:

<?xml version="1.0" encoding="utf-8" ?>
<customfunctions>
    <function name="function1" as="xs:anyAtomicType?" description="Function 1">
        <param name="value" as="xs:anyAtomicType?" />
        <sequence select="$value" />
    </function>
</customfunctions>

function2.xml:

<?xml version="1.0" encoding="utf-8" ?>
<customfunctions>
    <function name="function2" as="xs:anyAtomicType?" description="Function 2">
        <param name="value" as="xs:anyAtomicType?" />
        <sequence select="$value" />
    </function>
</customfunctions>

Screenshots or Videos

No response

Version

v2.119.4

Additional context

No response

hartra344 commented 6 months ago

@DanielleCogs this looks like it may be a backend issue rather than a frontend issue. Could you get this in front of them?

DanielleCogs commented 1 month ago

workitem created https://msazure.visualstudio.com/One/_workitems/edit/28966535