Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Custom Handlers]Metadata of DateTime type is serialized as string #6574

Closed
ZachTB123 opened this issue Aug 31, 2020 · 2 comments · Fixed by #6707
Closed

[Custom Handlers]Metadata of DateTime type is serialized as string #6574

ZachTB123 opened this issue Aug 31, 2020 · 2 comments · Fixed by #6707

Comments

@ZachTB123
Copy link

When creating a function with a ServiceBus input and logging the InvokeRequest, I am seeing something like the following in App Insights:

&{Data:map[queue:base64EncodedDataRedacted] Metadata:map[ContentType:"text/plain" DeliveryCount:11 EnqueuedTimeUtc:"2020-08-31T16:48:37.708Z" ExpiresAtUtc:"9999-12-31T23:59:59.9999999" LockToken:"7ebe3bcf-bae7-455e-99ea-568500a75173" MessageId:"883052175d7f490083127c81826fce10" ... (rest is omitted)]}

Notice that there are some keys in the Metadata map (e.g. ContentType, EnqueuedTimeUtc, LockToken, etc.) that have their values wrapped in double quotes (""). Note I've seen the trigger input (in this case queue) behave the same way (wrapped in double quotes) but have gotten around this by setting "dataType" to "binary" in the function.json file.

This is causing issues when I try and unmarshal this metadata map into a Golang struct where EnqueuedTimeUtc is of type time.Time:

type ServiceBusMessageMetadata struct {
	DeliveryCount   int       `json:"DeliveryCount,string"`
	EnqueuedTimeUtc time.Time `json:"EnqueuedTimeUtc"`
	ExpiresAtUtc    string    `json:"ExpiresAtUtc"`
	LockToken       string    `json:"LockToken"`
	MessageID       string    `json:"MessageId"`
}

My code is producing an error like the following when trying to unmarshal this:

failed to unmarshal servicebus metadata to ServiceBusMessageMetadata struct: parsing time ""\"2020-08-31T16:49:41.831Z\""" as ""2006-01-02T15:04:05Z07:00"": cannot parse "\"2020-08-31T16:49:41.831Z\""" as "2006"

I can validate this by running the following:

i := &InvokeRequest{
    Data: map[string]interface{}{
        "ContentType": "\"text/plain\"",
    },
}

fmt.Printf("I: %+v\n", i)

which produces:

I: &{Data:map[ContentType:"text/plain"] Metadata:map[]}

Notice that ContentType is surrounded in double quotes, exactly like how the InvokeRequest struct being handed to my function is.

Investigative information

Please provide the following:

  • Timestamp: 2020-08-31 17:29:56.3769396 +0000 GMT
  • Function App version: 3.0.14287.0
  • Invocation ID: 03de2715-246f-42bf-b161-15a9ed879d9d
  • Region: Central US
@ghost ghost assigned mhoeger Aug 31, 2020
@ZachTB123
Copy link
Author

@ZachTB123
Copy link
Author

A trigger such as timerTrigger does not have this issue:

Screen Shot 2020-08-31 at 12 50 51 PM

^ image of what logging the InvokeRequest for a timer trigger looks like in Application Insights

@pragnagopa pragnagopa assigned pragnagopa and unassigned mhoeger Sep 1, 2020
@pragnagopa pragnagopa added this to the Triaged milestone Sep 1, 2020
@yojagad yojagad assigned yojagad and unassigned pragnagopa Sep 15, 2020
@yojagad yojagad modified the milestones: Triaged, Functions Sprint 85 Sep 15, 2020
@anthonychu anthonychu added the GA label Sep 23, 2020
@pragnagopa pragnagopa changed the title [Custom Handlers - Go] Extra double quotes appearing in ServiceBus input [Custom Handlers][ServiceBusTrigger]Metadata for type Date type is serialized as string Sep 28, 2020
@pragnagopa pragnagopa changed the title [Custom Handlers][ServiceBusTrigger]Metadata for type Date type is serialized as string [Custom Handlers][ServiceBusTrigger]Metadata of Date type is serialized as string Sep 28, 2020
@pragnagopa pragnagopa assigned pragnagopa and unassigned yojagad Sep 28, 2020
@pragnagopa pragnagopa changed the title [Custom Handlers][ServiceBusTrigger]Metadata of Date type is serialized as string [Custom Handlers]Metadata of Date type is serialized as string Sep 28, 2020
@pragnagopa pragnagopa changed the title [Custom Handlers]Metadata of Date type is serialized as string [Custom Handlers]Metadata of DateTime type is serialized as string Sep 28, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Oct 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants