Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If you upload a file to a page that gets redirected by the 404 handler, you get a function clause error in boss_web_controller_handle_request:process_result #657

Open
RobertSwirsky opened this issue Oct 11, 2016 · 0 comments

Comments

@RobertSwirsky
Copy link

RobertSwirsky commented Oct 11, 2016

Here's what happens:

  • Do an http file upload to a URL that doesn't exist and gets handled by the 404 mechanism
  • add a POST handler to the 404 controller (though this will happen without it)

Here's my route

% 404 File Not Found handler
{404, [{controller, "unlogged"}, {action, "error404"}]}.

And this is the unlogged controller.

error404('GET', []) ->
    { ok, [] };
error404('POST', []) ->
    [{_, _FileName, TempLocation, _Size, _Name, _}|_] = Req:post_files(),
    file:delete(TempLocation),
    {output, "Go Away"}.

There will be a crash in boss_web_controller_handle_request:process_result because there's no matching function clause.

I added a catch-all at the end to see what we're getting:

% [ ... lots of clauses before this one ... ]
process_result(_, _, {StatusCode, Payload, Headers}) when is_integer(StatusCode) ->
    {StatusCode, boss_web_controller:merge_headers(Headers, [{"Content-Type", "text/html"}]), Payload};
process_result(_, _, X) ->
    lager:info("process_result! I have no idea: ~p", [X]).

And we got this output:

18:40:43.814 [info] process_result! I have no idea: {{ok,"Go Away",[]},undefined,[]}

The problem is those two extra params after the 3-element tuple aren't matched by any existing function header.

You'll have the same problem if the POST handler returned {json, []} or {ok, []} too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant