Azure / Azure/azure-functions-host

[csx] Invalid Function can still be invoked via the Portal and returns a 202, with no indicated error

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

Description

Create a bad csx function -- like below. It's got an additional parameter that doesn't correspond to any binding:

```
using System;

public static void Run(TimerInfo myTimer, ICollector output, ILogger log)
{
log.LogInformation("Hi!");
}
```

binding:
```
{
"bindings": [
{
"name": "myTimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "*/10 * * * * *"
}
]
}
```

Try to invoke it. You get a 202 Accepted. And no indication of any error, but also no streaming logs. Internally, the call to invoke this is failing early because the function isn't set up correctly. But that log doesn't get caught or reported anywhere.

There's a couple issues here:
1. In the portal, there's no indication of any error during compilation. The indexing error is logged to the host, rather than the function file. I see the correct FunctionIndexingException in my host logs.
2. When attempting to invoke, a better response needs to be given. This function wasn't invoked and had an issue -- we should be reporting that somewhere.

Contributor guide

Open the contributing guide

Research direction

Reproduce the invalid C# script with the extra unbound parameter and the timer binding shown in the issue, then inspect the host logs and portal invocation behavior. The work is done when indexing failures are surfaced to the portal and invoking the invalid function reports an error instead of returning 202 Accepted without logs.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.