{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/aspnet-api-versioning/issues/423","repository_url":"https://api.github.com/repos/Microsoft/aspnet-api-versioning","labels_url":"https://api.github.com/repos/Microsoft/aspnet-api-versioning/issues/423/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/aspnet-api-versioning/issues/423/comments","events_url":"https://api.github.com/repos/Microsoft/aspnet-api-versioning/issues/423/events","html_url":"https://github.com/Microsoft/aspnet-api-versioning/issues/423","id":395022835,"node_id":"MDU6SXNzdWUzOTUwMjI4MzU=","number":423,"title":"UnsupportedApiVersion error when route constraint prevents a match","user":{"login":"sugarjig","id":639693,"node_id":"MDQ6VXNlcjYzOTY5Mw==","avatar_url":"https://avatars0.githubusercontent.com/u/639693?v=4","gravatar_id":"","url":"https://api.github.com/users/sugarjig","html_url":"https://github.com/sugarjig","followers_url":"https://api.github.com/users/sugarjig/followers","following_url":"https://api.github.com/users/sugarjig/following{/other_user}","gists_url":"https://api.github.com/users/sugarjig/gists{/gist_id}","starred_url":"https://api.github.com/users/sugarjig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sugarjig/subscriptions","organizations_url":"https://api.github.com/users/sugarjig/orgs","repos_url":"https://api.github.com/users/sugarjig/repos","events_url":"https://api.github.com/users/sugarjig/events{/privacy}","received_events_url":"https://api.github.com/users/sugarjig/received_events","type":"User","site_admin":false},"labels":[{"id":593365604,"node_id":"MDU6TGFiZWw1OTMzNjU2MDQ=","url":"https://api.github.com/repos/Microsoft/aspnet-api-versioning/labels/asp.net%20core","name":"asp.net core","color":"5319e7","default":false},{"id":414438392,"node_id":"MDU6TGFiZWw0MTQ0MzgzOTI=","url":"https://api.github.com/repos/Microsoft/aspnet-api-versioning/labels/bug","name":"bug","color":"ee0701","default":true}],"state":"open","locked":false,"assignee":{"login":"commonsensesoftware","id":11765008,"node_id":"MDQ6VXNlcjExNzY1MDA4","avatar_url":"https://avatars1.githubusercontent.com/u/11765008?v=4","gravatar_id":"","url":"https://api.github.com/users/commonsensesoftware","html_url":"https://github.com/commonsensesoftware","followers_url":"https://api.github.com/users/commonsensesoftware/followers","following_url":"https://api.github.com/users/commonsensesoftware/following{/other_user}","gists_url":"https://api.github.com/users/commonsensesoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/commonsensesoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/commonsensesoftware/subscriptions","organizations_url":"https://api.github.com/users/commonsensesoftware/orgs","repos_url":"https://api.github.com/users/commonsensesoftware/repos","events_url":"https://api.github.com/users/commonsensesoftware/events{/privacy}","received_events_url":"https://api.github.com/users/commonsensesoftware/received_events","type":"User","site_admin":false},"assignees":[{"login":"commonsensesoftware","id":11765008,"node_id":"MDQ6VXNlcjExNzY1MDA4","avatar_url":"https://avatars1.githubusercontent.com/u/11765008?v=4","gravatar_id":"","url":"https://api.github.com/users/commonsensesoftware","html_url":"https://github.com/commonsensesoftware","followers_url":"https://api.github.com/users/commonsensesoftware/followers","following_url":"https://api.github.com/users/commonsensesoftware/following{/other_user}","gists_url":"https://api.github.com/users/commonsensesoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/commonsensesoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/commonsensesoftware/subscriptions","organizations_url":"https://api.github.com/users/commonsensesoftware/orgs","repos_url":"https://api.github.com/users/commonsensesoftware/repos","events_url":"https://api.github.com/users/commonsensesoftware/events{/privacy}","received_events_url":"https://api.github.com/users/commonsensesoftware/received_events","type":"User","site_admin":false}],"milestone":null,"comments":0,"created_at":"2018-12-31T19:30:08Z","updated_at":"2018-12-31T22:37:50Z","closed_at":null,"author_association":"NONE","body":"I have a controller with an action that specifies a route constraint. Here is a snippet.\r\n```csharp\r\nnamespace Foo\r\n{\r\n    [ApiVersion(\"1.0\")]\r\n    [Produces(\"application/json\")]\r\n    [Route(\"api/v{version:apiVersion}/[controller]\")]\r\n    [ApiController]\r\n    public sealed class ValuesController : ControllerBase\r\n    {\r\n        [HttpPut(\"{id:guid}\")]\r\n        public async Task<IActionResult> PutValueAsync(\r\n            [FromRoute] Guid id,\r\n            [FromBody] Value value)\r\n        {\r\n        }\r\n    }\r\n```\r\nIf I make a request with a valid GUID in the path (i.e. `PUT /api/v1/12345678-90ab-cdef-1234-567890abcdef`), everything works as expected. But if I use an invalid GUID in the path (e.g. `PUT /api/v1/1234`), I get a 400 with the following body:\r\n```json\r\n{\r\n    \"error\": {\r\n        \"code\": \"UnsupportedApiVersion\",\r\n        \"message\": \"The HTTP resource that matches the request URI 'https://localhost:5001/api/v1/consumers/be4d7d66-f01d-4766-a71d-66c0d82d947/consumption' does not support the API version '1'.\",\r\n        \"innerError\": null\r\n    }\r\n}\r\n```\r\nI'm expecting a 404 because no route is supposed to match, according to the [documentation](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-2.2#route-constraint-reference).\r\n\r\nI'm using ASP.NET Core 2.2 and API Versioning version 3.1."},"comment":{"url":"https://api.github.com/repos/Microsoft/aspnet-api-versioning/issues/comments/450696228","html_url":"https://github.com/Microsoft/aspnet-api-versioning/issues/423#issuecomment-450696228","issue_url":"https://api.github.com/repos/Microsoft/aspnet-api-versioning/issues/423","id":450696228,"node_id":"MDEyOklzc3VlQ29tbWVudDQ1MDY5NjIyOA==","user":{"login":"commonsensesoftware","id":11765008,"node_id":"MDQ6VXNlcjExNzY1MDA4","avatar_url":"https://avatars1.githubusercontent.com/u/11765008?v=4","gravatar_id":"","url":"https://api.github.com/users/commonsensesoftware","html_url":"https://github.com/commonsensesoftware","followers_url":"https://api.github.com/users/commonsensesoftware/followers","following_url":"https://api.github.com/users/commonsensesoftware/following{/other_user}","gists_url":"https://api.github.com/users/commonsensesoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/commonsensesoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/commonsensesoftware/subscriptions","organizations_url":"https://api.github.com/users/commonsensesoftware/orgs","repos_url":"https://api.github.com/users/commonsensesoftware/repos","events_url":"https://api.github.com/users/commonsensesoftware/events{/privacy}","received_events_url":"https://api.github.com/users/commonsensesoftware/received_events","type":"User","site_admin":false},"created_at":"2018-12-31T22:37:50Z","updated_at":"2018-12-31T22:37:50Z","author_association":"MEMBER","body":"Technically, this has been the existing behavior for API versioning due to limitations in the routing system. _Endpoint Routing_ addresses most of these limitations. I had things short-circuiting if a candidate is already invalid. This might exclude candidates that match the requested API version, but are already invalid (ex: due to an invalid route constraint) and ultimately produce an unexpected response. Since this wasn't the expected intent, I'll consider it a bug.  I should have the fix out shortly.\r\n\r\nFor future reference, here are the behavioral differences:\r\n\r\n**Legacy Routing**\r\n\r\n| Status Code | Source | Description |\r\n| ------------- | -------- | ------------ |\r\n| 400 | API Versioning | No matching API versions |\r\n| 400 | API Versioning | Possible candidates, but no matches |\r\n| 400 | ASP.NET | Invalid model state |\r\n| 404 | ASP.NET | No matching candidates |\r\n| 405 | API Versioning | No matching HTTP method |\r\n\r\n**Endpoint Routing**\r\n\r\n| Status Code | Source | Description |\r\n| ------------- | -------- | ------------ |\r\n| 400 | API Versioning | No matching API versions |\r\n| 400 | ASP.NET | Invalid model state |\r\n| 404 | ASP.NET | No matching candidates |\r\n| 405 | ASP.NET | No matching HTTP method |"}}
{"actor":{"display_login":"commonsensesoftware"}}