Skip to content

Cannot type-hint TimeSpan in Durable activity input #1110

Open
@andystaples

Description

@andystaples

If I define a Durable activity function and type-hint the input to [TimeSpan] like so:

param([TimeSpan]$in)

"Hello $in!"

The activity will fail when attempting to call this activity with the following error:

[2025-06-25T19:04:34.086Z] EXCEPTION: Cannot process argument transformation on parameter 'in'. Cannot create object of type "System.TimeSpan". "Ticks" is a ReadOnly property.
[2025-06-25T19:04:34.087Z]
[2025-06-25T19:04:34.088Z] Exception             :
[2025-06-25T19:04:34.089Z]     Type    : System.Management.Automation.ParentContainsErrorRecordException
[2025-06-25T19:04:34.090Z]     Message : Cannot process argument transformation on parameter 'in'. Cannot create object of type "System.TimeSpan". "Ticks" is a ReadOnly property.
[2025-06-25T19:04:34.091Z]     HResult : -2146233087
[2025-06-25T19:04:34.092Z] CategoryInfo          : InvalidData: (:) [_InputCheckTimeSpan_], ParentContainsErrorRecordException
[2025-06-25T19:04:34.093Z] FullyQualifiedErrorId : ParameterArgumentTransformationError,_InputCheckTimeSpan_
[2025-06-25T19:04:34.094Z] InvocationInfo        :
[2025-06-25T19:04:34.095Z]     MyCommand       : _InputCheckTimeSpan_
[2025-06-25T19:04:34.096Z]     HistoryId       : 1
[2025-06-25T19:04:34.097Z]     CommandOrigin   : Internal
[2025-06-25T19:04:34.099Z]
[2025-06-25T19:04:34.099Z]
[2025-06-25T19:04:34.125Z] Executed 'Functions.InputCheckTimeSpan' (Failed, Id=d66f053f-04ed-4383-91c8-41342e6d2462, Duration=282ms)
[2025-06-25T19:04:34.126Z] System.Private.CoreLib: Exception while executing function: Functions.InputCheckTimeSpan. System.Private.CoreLib: Result: Failure
Exception: Cannot process argument transformation on parameter 'in'. Cannot create object of type "System.TimeSpan". "Ticks" is a ReadOnly property.
Stack:    at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
[2025-06-25T19:04:34.128Z]    at System.Management.Automation.Runspaces.Pipeline.Invoke()
[2025-06-25T19:04:34.129Z]    at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
[2025-06-25T19:04:34.130Z]    at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
[2025-06-25T19:04:34.132Z]    at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
[2025-06-25T19:04:34.133Z]    at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
[2025-06-25T19:04:34.134Z]    at System.Management.Automation.PowerShell.CoreInvoke[TOutput](IEnumerable input, PSDataCollection`1 output, PSInvocationSettings settings)
[2025-06-25T19:04:34.135Z]    at System.Management.Automation.PowerShell.Invoke[T](IEnumerable input, IList`1 output, PSInvocationSettings settings)
[2025-06-25T19:04:34.136Z]    at System.Management.Automation.PowerShell.Invoke[T]()
[2025-06-25T19:04:34.138Z]    at Microsoft.Azure.Functions.PowerShellWorker.PowerShell.PowerShellExtensions.InvokeAndClearCommands[T](PowerShell pwsh)
[2025-06-25T19:04:34.139Z]    at Microsoft.Azure.Functions.PowerShellWorker.PowerShell.PowerShellManager.ExecuteUserCode(Boolean addPipelineOutput, IDictionary outputBindings)
[2025-06-25T19:04:34.140Z]    at Microsoft.Azure.Functions.PowerShellWorker.PowerShell.PowerShellManager.InvokeFunction(AzFunctionInfo functionInfo, Hashtable triggerMetadata, TraceContext traceContext, RetryContext retryContext, IList`1 inputData, FunctionInvocationPerformanceStopwatch stopwatch, OpenTelemetryInvocationContext otelContext)
[2025-06-25T19:04:34.141Z]    at Microsoft.Azure.Functions.PowerShellWorker.RequestProcessor.InvokeFunction(AzFunctionInfo functionInfo, PowerShellManager psManager, FunctionInvocationPerformanceStopwatch stopwatch, InvocationRequest invocationRequest)
[2025-06-25T19:04:34.142Z]    at Microsoft.Azure.Functions.PowerShellWorker.RequestProcessor.ProcessInvocationRequestImpl(StreamingMessage request, AzFunctionInfo functionInfo, PowerShellManager psManager, FunctionInvocationPerformanceStopwatch stopwatch).
[2025-06-25T19:04:34.163Z] ee917473-3287-4ef0-afaa-8abdd20e35e7: Function 'InputCheckTimeSpan (Activity)' failed with an error. Reason: System.Exception
. IsReplay: False. State: Failed. RuntimeStatus: Failed. HubName: TestHubName. AppName: . SlotName: . ExtensionVersion: 3.2.0. SequenceNumber: 19. TaskEventId: 3

This exception seems to be coming from the PowerShell SDK internally when it tries to automatically reform whatever Json/HashTable/other data structure is coming from the Durable backend into the TimeSpan using some non-standard constructor.

It may be possible for us to shim this behavior away in the Functions PS worker or the Durable SDK, need to investigate more

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions