Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.47k stars 4.8k forks source link

[BUG] WebActivityAuthentication Username property does not allow for expressions #37749

Open mikegoatly opened 1 year ago

mikegoatly commented 1 year ago

Library name and version

Azure.Analytics.Synapse.Artifacts 1.0.0-preview.17

Describe the bug

The Username property on WebActivityAuthentication is defined as a string:

public string Username { get; set; }

However in Synapse this property can be defined as an expression, and when this is the case, deserialization fails with the following error:

Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.InvalidOperationException: The requested operation requires an element of type 'String', but the target element has type 'Object'.
   at System.Text.Json.JsonDocument.GetString(Int32 index, JsonTokenType expectedType)
   at Azure.Analytics.Synapse.Artifacts.Models.WebActivityAuthentication.DeserializeWebActivityAuthentication(JsonElement element)
   at Azure.Analytics.Synapse.Artifacts.Models.WebActivity.DeserializeWebActivity(JsonElement element)
   at Azure.Analytics.Synapse.Artifacts.Models.Activity.DeserializeActivity(JsonElement element)
   at Azure.Analytics.Synapse.Artifacts.Models.ForEachActivity.DeserializeForEachActivity(JsonElement element)
   at Azure.Analytics.Synapse.Artifacts.Models.Activity.DeserializeActivity(JsonElement element)
   at Azure.Analytics.Synapse.Artifacts.Models.PipelineResource.DeserializePipelineResource(JsonElement element)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Microsoft.Azure.Commands.Synapse.Common.JsonConvert.DeserializeObject[T](String rawJsonContent)
   at Microsoft.Azure.Commands.Synapse.Models.SynapseAnalyticsArtifactsClient.CreateOrUpdatePipeline(String pipelineName, String rawJsonContent)
   at Microsoft.Azure.Commands.Synapse.SetAzureSynapsePipeline.ExecuteCmdlet()
   at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()

Expected behavior

No exception should be thrown when deserializing a WebActivityAuthentication when the user name is set to an expression.

Actual behavior

An exception is thrown.

Reproduction Steps

  1. Define a pipeline in Synapse that uses a WebActivity and sets the username property to an expression, e.g. bind it to a parameter or variable
  2. Deserialize the pipeline's JSON using the SDK
  3. The exception is thrown

Environment

No response

github-actions[bot] commented 1 year ago

Thank you for your feedback. This has been routed to the support team for assistance.

navba-MSFT commented 1 year ago

Adding Service team to look into this.

github-actions[bot] commented 1 year ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @wonner @yanjungao718 @pshao25

wonner commented 1 year ago

Thanks for the report. @Jingshu923 will help fix, thanks