microsoft / PowerPlatformConnectors

This is a repository for Microsoft Power Automate, Power Apps, and Azure Logic Apps connectors
https://aka.ms/connectors
MIT License
977 stars 1.26k forks source link

[BUG] InternalServerError when using script #1925

Open ben741 opened 2 years ago

ben741 commented 2 years ago

Type of Connector

Custom Connector

Name of Connector

Any (in development)

Describe the bug

When developing a connector and using custom scripting, operations frequently fail with an InternalServerError message and no further details.

This even happens for a trivial script that just forwards the request:

public class Script : ScriptBase
{
    public override async Task<HttpResponseMessage> ExecuteAsync()
    {
        HttpResponseMessage response = await this.Context.SendAsync(this.Context.Request, this.CancellationToken).ConfigureAwait(continueOnCapturedContext: false);
        return response;
    }
}

It tends to happen more often for "cold starts" - a second request tends to succeed.

Is this a security bug?

No, this is not a security bug

What is the severity of this bug?

Severity 2 - One or more important connector features are down

To Reproduce

Create a custom connector and enable a custom script (such as the one in the description above). Test/run it as part of an "Instant Cloud Flow."

Expected behavior

The connector should work each time, with no InternalServerErrror.

Environment summary

paconn --version
0.0.20

Additional context

The specifics of the API definition and script content don't seem to matter.

dgtvan commented 2 years ago

I am also experiencing the similar issue. It took me days to try to troubleshoot, it turns out the Context.SendAsync is the culprit. It causes 403 error.

image

ben741 commented 2 years ago

I think you have a different issue. Mine is a 500 status, not 403. Thanks for the screenshot though - I hadn't thought to check the custom connector test panel (rather than the flow run) to see if there would be more information there.

It seems like the issue I'm having is that my script exceeds the 5 second limit when running from a cold start, i.e. the timeout is being applied to more than just the execution time for the script itself, which is trivial and should take milliseconds to run. A manual retry usually succeeds.

power-automate-500

dgtvan commented 2 years ago

Thank @ben741 I will probably create a separate topic for my issue.

Enomis82 commented 3 months ago

Any news on that issue? we have the same problem. if we create a custom connector Action without code it work fine but if we enable code in order to change body request message and manage response the method this.Context.SendAsync return a 403 - Forbidden result.