Azure / Azure/azure-functions-host

HTTP model binding can't handle DateTimes with seconds

Open
#4,134 3 comments 0 reactions 0 assignees View on GitHub
bug needs-investigation
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 12h
Merged PRs (30d)
38

Description

I have a C# v2 Function with an HTTP trigger that looks like this:
```
public static async Task Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] MyParameters parameters,
ILogger log, ExecutionContext context)
```
The `MyParameters` class has a `DateTime` property.
If I run this in Azure and use Postman to POST JSON to it with the `DateTime` property set to "2019-01-28T13:23:34.12345Z" it works fine.

If I run it locally and use Postman to POST to it with the same value I get the following error:
```
[23/02/2019 15:33:11] System.Private.CoreLib: Exception while executing function: MyFunction. Microsoft.Azure.WebJobs.Host:
Exception binding parameter 'parameters'. System.Private.CoreLib: String '01/28/2019 13:23:34' was not recognized as a valid DateTime.
```
Note that the local locale is en-GB - not that that should make a difference to it working.

If I remove the seconds from the `DateTime` property, i.e. "2019-01-28T13:23" it works locally.

Contributor guide

Open the contributing guide

Research direction

Reproduce the HTTP-trigger model binding locally with the MyParameters DateTime value "2019-01-28T13:23:34.12345Z", then compare it with the Azure behavior described in the issue. Trace the local binding and DateTime parsing entry point; done means local binding accepts the same timestamp, including seconds, without the reported exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.