Azure / Azure/azure-functions-powershell-worker

Cannot type-hint TimeSpan in Durable activity input

Open
#1,110 0 comments 0 reactions 0 assignees View on GitHub
feature:durable functions P2
Dominant language
C#
Stars
215
Forks
61
Avg merge
21h 4m
Merged PRs (30d)
6

Description

If I define a Durable activity function and type-hint the input to [TimeSpan] like so:
```powershell
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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the typed TimeSpan Durable activity input shown in the issue and trace the PowerShell worker's activity invocation and automatic argument conversion. Determine whether the failure occurs in the Functions PowerShell worker or the Durable SDK, then add a regression test covering successful TimeSpan input conversion.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp, powershell
Domain
backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.