{"action":"created","issue":{"url":"https://api.github.com/repos/Starcounter/Starcounter/issues/3126","labels_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/3126/labels{/name}","comments_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/3126/comments","events_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/3126/events","html_url":"https://github.com/Starcounter/Starcounter/issues/3126","id":119818359,"number":3126,"title":"Merged response end up empty via layers of handlers","user":{"login":"per-samuelsson","id":2902045,"avatar_url":"https://avatars.githubusercontent.com/u/2902045?v=3","gravatar_id":"","url":"https://api.github.com/users/per-samuelsson","html_url":"https://github.com/per-samuelsson","followers_url":"https://api.github.com/users/per-samuelsson/followers","following_url":"https://api.github.com/users/per-samuelsson/following{/other_user}","gists_url":"https://api.github.com/users/per-samuelsson/gists{/gist_id}","starred_url":"https://api.github.com/users/per-samuelsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/per-samuelsson/subscriptions","organizations_url":"https://api.github.com/users/per-samuelsson/orgs","repos_url":"https://api.github.com/users/per-samuelsson/repos","events_url":"https://api.github.com/users/per-samuelsson/events{/privacy}","received_events_url":"https://api.github.com/users/per-samuelsson/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Starcounter/Starcounter/labels/bug","name":"bug","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-01T22:03:59Z","updated_at":"2015-12-02T06:02:34Z","closed_at":null,"body":"This bug is kind of tricky. Me, @warpech and @jwillmer has spent the majority of the day today trying to figure it out. We found a way around it earlier today, but didn't understand the full picture. Now I've nailed it (after yet a few hours trying to trim it), but it spans several layers, so I'm not sure who should look into it though.\r\n\r\nHere it goes:\r\n\r\nA) Create an application that runs under the control of some launcher. Its reproducable in the default launcher if I build that from the latest sources today.\r\n\r\nB) Register a handler like this:\r\n\r\n```C#\r\nHandle.GET(\"/foo/bartest\", () => {\r\n  return new BarPage();\r\n}\r\n```\r\n\r\nThe BarPage JSON should have a \"Html\" property referencing \"BarPage.html\".\r\n\r\nC) Register another handler like this:\r\n\r\n```C#\r\nHandle.GET(\"/foo/bar{?}\", () => {\r\n  return Self.GET(\"/foo/bartest\");\r\n}\r\n```\r\n\r\n**NOTE**: Make sure you do the template string right - it's *meant* to be `/foo/bar/{?}` (i.e. with a slash), but there is a **typo** (i.e. we are *missing* the slash), and hence it acts differently.\r\n\r\nD) Run and fetch `/foo/bartest`.\r\n\r\nWhat will happen is\r\n\r\n1. The `/foo/bartest` request come along. It's mapped to our [B] handler, and rightly so.\r\n2. Next comes a merge request, hitting the launcher. That one will hit `Handle.GET(StarcounterConstants.HtmlMergerPrefix + \"{?}\", (String s) => { ..} ` handler registered [here in LauncherHelper](https://github.com/StarcounterSamples/Launcher/blob/master/src/Launcher/Api/LauncherHelper.cs#L149). The input will be something along the line with `\"/sc/htmlmerger?[...]foo/BarPage.html\"`. The handler will chop the string up, and eventually invoke `Self.GET(\"foo/BarPage.html\")` done [here](https://github.com/StarcounterSamples/Launcher/blob/master/src/Launcher/Api/LauncherHelper.cs#L161). This will in turn reach our handler in [C], that will invoke [B] and the merged result we get will be blank. Exactly why it turns out blank/empty in the merged response, I don't know, Maybe it has to do with the explicit handler options of that merge handler?\r\n\r\nI have an environment where this can be reproduced constantly and debugged if someone's willing to take it on!\r\n\r\nSorry if this one belongs somewhere else. I just cant tell whats wrong here, if its launcher or uri matcher or some handlers level. Maybe we can't even do anything to address it (since its somewhat caused by the handler typo) but we sure should try, because someone else will do something similar for certain, and its a mess trying to find out what goes wrong.\r\n\r\nI'll label it a bug until someone convince me its not. :smile: "},"comment":{"url":"https://api.github.com/repos/Starcounter/Starcounter/issues/comments/161189553","html_url":"https://github.com/Starcounter/Starcounter/issues/3126#issuecomment-161189553","issue_url":"https://api.github.com/repos/Starcounter/Starcounter/issues/3126","id":161189553,"user":{"login":"per-samuelsson","id":2902045,"avatar_url":"https://avatars.githubusercontent.com/u/2902045?v=3","gravatar_id":"","url":"https://api.github.com/users/per-samuelsson","html_url":"https://github.com/per-samuelsson","followers_url":"https://api.github.com/users/per-samuelsson/followers","following_url":"https://api.github.com/users/per-samuelsson/following{/other_user}","gists_url":"https://api.github.com/users/per-samuelsson/gists{/gist_id}","starred_url":"https://api.github.com/users/per-samuelsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/per-samuelsson/subscriptions","organizations_url":"https://api.github.com/users/per-samuelsson/orgs","repos_url":"https://api.github.com/users/per-samuelsson/repos","events_url":"https://api.github.com/users/per-samuelsson/events{/privacy}","received_events_url":"https://api.github.com/users/per-samuelsson/received_events","type":"User","site_admin":false},"created_at":"2015-12-02T06:02:34Z","updated_at":"2015-12-02T06:02:34Z","body":"After sleeping on it, I can see the heart of the problem clearer: the (misspelled) [C] handler will \"hide\" static content, because it's pattern overlap static files with that naming scheme.\r\n\r\nSome suggestions on how we possibly can improve:\r\n\r\n1. Always assure we merge just `html` responses (this one returned JSON, thats why the result ended up crappy)\r\n2. Check handlers at registration and compare there regex to static content. If a handler \"hide\" static content, we enforce some special registration means (i.e. forcing the user to state he knows what hes doing).\r\n3. Assure the \"Html\" property always bind to static content and/or verify the response, checking that was requested was actually returned. Not sure if this will limit the product though.\r\n\r\n@warpech @alemoi @miyconst WDYT?"}}