question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could you provide an example of CloudEventDataConverterAttribute

See original GitHub issue

I have the below simple event function:

open Google.Cloud.Functions.Framework
open Google.Events
open Google.Events.Protobuf.Cloud.PubSub.V1
open System.Threading.Tasks

type Function() =
    interface ICloudEventFunction<PubsubMessage> with
        
        member this.HandleAsync(cloudEvent, data, cancellationToken) =

            printfn "%s" data.TextData

            Task.CompletedTask

When deployed I get the error:

System.InvalidOperationException: Unable to create data converter for target type Google.Events.Protobuf.Cloud.PubSub.V1.PubsubMessage
 ---> System.ArgumentException: Type Google.Events.Protobuf.Cloud.PubSub.V1.PubsubMessage does not have CloudEventDataConverterAttribute applied to it.
   at Google.Events.CloudEventConverters.CreateDataConverter[T]()
   --- End of inner exception stack trace ---
   at Google.Events.CloudEventConverters.CreateDataConverter[T]()
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Google.Events.CloudEventConverters.GetDataConverter[T]()
   at Google.Events.CloudEventConverters.ConvertCloudEventData[T](CloudEvent cloudEvent)
   at Google.Cloud.Functions.Framework.CloudEventAdapter`1.HandleAsync(HttpContext context)
   at Google.Cloud.Functions.Hosting.HostingInternals.Execute(HttpContext context)
   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

The README says the type in the ICloudEventFunction should have the CloudEventDataConverterAttribute applied to it but I would have thought GCP types would already have this?

Could you give an example of how to apply CloudEventDataConverterAttribute to types?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jskeetcommented, Feb 22, 2021

@vestigialdev: Yup - sorry for taking too long to work out that’s what you meant. (First coffee of the day hadn’t fully kicked in.)

It turns out there were issues with some other snippets too. I’m fixing those up, and also trying to work out why this wasn’t caught in automated testing. Thanks for spotting it and drawing my attention to it.

0reactions
BestDigital22commented, Feb 22, 2021

Sorry for being unclear- I do mean that the template generated by the Cloud Console (rather than using powershell locally to run dotnet new gcf-event) seems to output a bad Function.cs that doesn’t compile/deploy

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found