aspnet / WebHooks

[Archived] Libraries to create and consume web hooks on ASP.NET Core. Project moved to https://github.com/aspnet/AspLabs
Apache License 2.0
627 stars 439 forks source link

Remove ambiguity between general WebHook action and receiver-specific action #291

Closed dougbu closed 6 years ago

dougbu commented 6 years ago

With the following WebHook actions

[GitHubWebHook]
public IActionResult GitHubHandler(string id, string @event, JObject data)
{
    return Ok();
}

[GeneralWebHook]
public IActionResult FallbackHandler(string receiverName, string id, string eventName)
{
    return Ok();
}

A request to https://localhost/api/webhooks/incoming/github should match the GitHubHandler(...) action. Instead, the request results in an error:

Microsoft.AspNetCore.Mvc.Internal.AmbiguousActionException : Multiple actions matched. The following actions matched route data and had all constraints satisfied:

GitHubCoreReceiver.Controllers.GitHubController.GitHubHandler (GitHubCoreReceiver)
GitHubCoreReceiver.Controllers.GitHubController.FallbackHandler (GitHubCoreReceiver)

This issue is not specific to the GitHub receiver. Instead, it's an unintended side effect of using the same constraint (WebHookReceiverNameConstraint) for both [GeneralWebHook] and receiver-specific attributes.

Fix is to reduce the Order of the WebHookReceiverNameConstraint when adding it for a receiver-specific attribute.

dougbu commented 6 years ago

Self-assigning because I'd otherwise need to work around this issue in my #290 efforts. That workaround would then need to be removed once we fix this.

dougbu commented 6 years ago

de678debde