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

SendGrid error when used in durable Orchestrator function #952

Open
GMedlin opened this issue May 2, 2023 · 1 comment
Open

SendGrid error when used in durable Orchestrator function #952

GMedlin opened this issue May 2, 2023 · 1 comment

Comments

@GMedlin
Copy link

GMedlin commented May 2, 2023

I'm not sure if I'm doing something wrong, but to test this issue I created a new function project. I added a durable http starter function, an orchestrator function, and the SendGrid function all using the command palette templates.

When I run this function locally and call the endpoint to kick off an orchestrator instance, the SendGrid function successfully sends an email. However, when the orchestrator does its "replay" immediately after that function executes, it generates an exception saying ERROR: Value cannot be null. (Parameter 'input'). I'm not sure how this is possible. It shouldn't be trying to execute again, since the replay should remember that it already did. Also, the 'input' (which for testing I just set to 'Hello') is definitely not null.

See codebelow and the attached error message.

I updated my Orchestrator run.ps1 to this:

param($Context)

Write-Host "Hello from SendGrid activity!"
Invoke-DurableActivity -FunctionName 'SendGrid' -Input 'Test'

My SendGrid run.ps1 is below:

param($email, $TriggerMetadata)

Push-OutputBinding -Name 'Message' -Value (@{
    subject = "Thanks for your order $($email)!"
    content = @(@{
        type = 'text/plain'
        value = "Hi, thanks for your order!"
    })
})

SendGrid's function.json (email addresses removed for privacy):

{
  "bindings": [
    {
      "type": "activityTrigger",
      "name": "email",
      "direction": "in"
    },
    {
      "type": "sendGrid",
      "name": "message",
      "direction": "out",
      "apiKey": "SEND_GRID_API_KEY",
      "from": "x",
      "to": "x",
      "subject": "Test"
    }
  ]
}

Error Message.txt

@GMedlin
Copy link
Author

GMedlin commented May 2, 2023

I've tried a couple of workarounds. I can use try/catch to catch the error that's caused by the 2nd/replay execution of the SendGrid function. The downside is I won't be aware of a legit error. The other thing I've tried successfully is calling SendGrid using its REST API in a function rather than using the output binding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants