{"action":"created","issue":{"url":"https://api.github.com/repos/symfony/symfony/issues/17744","repository_url":"https://api.github.com/repos/symfony/symfony","labels_url":"https://api.github.com/repos/symfony/symfony/issues/17744/labels{/name}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/17744/comments","events_url":"https://api.github.com/repos/symfony/symfony/issues/17744/events","html_url":"https://github.com/symfony/symfony/pull/17744","id":132529292,"number":17744,"title":"Improve error reporting in router panel of web profiler","user":{"login":"javiereguiluz","id":73419,"avatar_url":"https://avatars.githubusercontent.com/u/73419?v=3","gravatar_id":"","url":"https://api.github.com/users/javiereguiluz","html_url":"https://github.com/javiereguiluz","followers_url":"https://api.github.com/users/javiereguiluz/followers","following_url":"https://api.github.com/users/javiereguiluz/following{/other_user}","gists_url":"https://api.github.com/users/javiereguiluz/gists{/gist_id}","starred_url":"https://api.github.com/users/javiereguiluz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javiereguiluz/subscriptions","organizations_url":"https://api.github.com/users/javiereguiluz/orgs","repos_url":"https://api.github.com/users/javiereguiluz/repos","events_url":"https://api.github.com/users/javiereguiluz/events{/privacy}","received_events_url":"https://api.github.com/users/javiereguiluz/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/symfony/symfony/labels/Bug","name":"Bug","color":"e10c02"},{"url":"https://api.github.com/repos/symfony/symfony/labels/Routing","name":"Routing","color":"DDDDDD"},{"url":"https://api.github.com/repos/symfony/symfony/labels/Status:%20Needs%20Work","name":"Status: Needs Work","color":"fad8c7"},{"url":"https://api.github.com/repos/symfony/symfony/labels/WebProfilerBundle","name":"WebProfilerBundle","color":"DDDDDD"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2016-02-09T20:48:36Z","updated_at":"2016-03-03T13:45:23Z","closed_at":"2016-03-03T13:13:12Z","pull_request":{"url":"https://api.github.com/repos/symfony/symfony/pulls/17744","html_url":"https://github.com/symfony/symfony/pull/17744","diff_url":"https://github.com/symfony/symfony/pull/17744.diff","patch_url":"https://github.com/symfony/symfony/pull/17744.patch"},"body":"| Q             | A\r\n| ------------- | ---\r\n| Bug fix?      | yes\r\n| New feature?  | no\r\n| BC breaks?    | no\r\n| Deprecations? | no\r\n| Tests pass?   | yes\r\n| Fixed tickets | #17342\r\n| License       | MIT\r\n| Doc PR        | -\r\n\r\n### Problem\r\n\r\nIf you define a route condition like this:\r\n\r\n```yaml\r\napp:\r\n    resource: '@AppBundle/Controller/'\r\n    type:     annotation\r\n    condition: \"request.server.get('HTTP_HOST') matches '/.*\\.dev/'\"\r\n```\r\n\r\nWhen browsing the Routing panel in the web profiler, you see an exception:\r\n\r\n![problem](https://cloud.githubusercontent.com/assets/73419/12930027/553eeb08-cf76-11e5-90b1-ab0de6175d4e.png)\r\n\r\n#### Why?\r\n\r\nBecause the route condition uses the `request` object, but the special `TraceableUrlMatcher` class doesn't get access to the real `request` object but to the special object obtained via:\r\n\r\n```php\r\n$request = $profile->getCollector('request');\r\n```\r\n\r\nThese are the contents of this pseudo-request:\r\n\r\n![cause](https://cloud.githubusercontent.com/assets/73419/12930052/804ea248-cf76-11e5-9c38-2e43e1654065.png)\r\n\r\n`request.server.get(...)` condition fails because `request.server` is `null`. The full exception message shows this:\r\n\r\n![exception](https://cloud.githubusercontent.com/assets/73419/12930079/9c7d6058-cf76-11e5-8eeb-45f5059c824c.png)\r\n\r\n### Solution\r\n\r\nI propose to catch all exceptions in `TraceableUrlMatcher` and display an error message with some details of the exception:\r\n\r\n![error_message](https://cloud.githubusercontent.com/assets/73419/12930106/b29e31d2-cf76-11e5-868c-98d8b0cc4e5b.png)\r\n"},"comment":{"url":"https://api.github.com/repos/symfony/symfony/issues/comments/191765504","html_url":"https://github.com/symfony/symfony/pull/17744#issuecomment-191765504","issue_url":"https://api.github.com/repos/symfony/symfony/issues/17744","id":191765504,"user":{"login":"stof","id":439401,"avatar_url":"https://avatars.githubusercontent.com/u/439401?v=3","gravatar_id":"","url":"https://api.github.com/users/stof","html_url":"https://github.com/stof","followers_url":"https://api.github.com/users/stof/followers","following_url":"https://api.github.com/users/stof/following{/other_user}","gists_url":"https://api.github.com/users/stof/gists{/gist_id}","starred_url":"https://api.github.com/users/stof/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stof/subscriptions","organizations_url":"https://api.github.com/users/stof/orgs","repos_url":"https://api.github.com/users/stof/repos","events_url":"https://api.github.com/users/stof/events{/privacy}","received_events_url":"https://api.github.com/users/stof/received_events","type":"User","site_admin":false},"created_at":"2016-03-03T13:45:23Z","updated_at":"2016-03-03T13:45:23Z","body":"@javiereguiluz not passing a Request object when evaluating the condition should be considered as a bug IMO. Assuming that the collector has a compatible-enough API is not fine."}}