Azure / Azure/azure-functions-host
Function-routes should not be compared against proxy-routes when checking for route conflicts
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 38
Description
Function route mapping fails for functions whose routes match with one of the proxy routes. The issue did not exist in v2 runtime. The behavior is highly dependent on how the proxy and the function are named (which governs the order in which their routes get mapped).
The regression seems to be introduced by commit https://github.com/Azure/azure-functions-host/commit/af6d87c2dfba0893177acd768d2d60a41a608626. Before this commit, all of the functions routes would always precede the proxy routes which helped in preventing the issue from happening.
#### Repro steps
1. Clone the Function App code from here: https://github.com/JatinSanghvi/azure-functions-route-conflict
2. Run `func host start` in the repo directory.
#### Actual behavior
The local Function host does not register `d2function` because it finds it to be conflicting with `d1proxy` which also maps the same route. However, as said in the issue title, Function routes should not be compared against proxy routes, as by design, the proxy routes take precedence over the function routes. Below is the log output:
```
[2021-09-14T06:13:51.624Z] The 'd2function' function is in error: The route specified conflicts with the route defined by function 'd1proxy'.
Functions:
a1function: [POST] http://localhost:7071/a1function
a2proxy: [POST] http://localhost:7071/a1function
b1proxy: [POST] http://localhost:7071/b2function
b2function: [POST] http://localhost:7071/b2function
c1function: http://localhost:7071/c1function
c2proxy: [POST] http://localhost:7071/c1function
d1proxy: [POST] http://localhost:7071/d2function
```
Summarizing the above behavior in table below:
| HTTP Route | Earlier route type + Method | Later route type + Method | Conflict Detected |
|---|---|---|---|
| `/a1function` | Function + POST | Proxy + POST | No |
| `/b2function` | Proxy + POST | Function + POST | No |
| `/c1function` | Function + all methods | Proxy + POST | No |
| `/d2function` | Proxy + POST | Function + all methods | Yes |
As shown in the table above, the path conflict is not flagged if the function has HTTP method constraint applied. This points to another issue that needs to be checked.
#### Expected behavior
1. Function `d2function` should not cause an error above (to be consistent with v2). It should be registered as one of the routes.
2. Behavior should not be dependent on naming of functions and proxies. As can be seen in table above, `/c1function` route does not result in a conflict.
3. Behavior should be consistent between functions with method constraints (e.g. `[POST, GET]`) or without method constraints.
#### Known workarounds
Rename the proxy name in `proxies.json` file so that it comes later in the alphabetical order than the name of function that has the same route.
#### Related information
* Programming language used : JavaScript
* Links to source: https://github.com/JatinSanghvi/azure-functions-route-conflict
* Bindings used: HTTP trigger
Contributor guide
Assessment
This issue has not been assessed yet.