{"action":"created","issue":{"url":"https://api.github.com/repos/rack/rack/issues/903","repository_url":"https://api.github.com/repos/rack/rack","labels_url":"https://api.github.com/repos/rack/rack/issues/903/labels{/name}","comments_url":"https://api.github.com/repos/rack/rack/issues/903/comments","events_url":"https://api.github.com/repos/rack/rack/issues/903/events","html_url":"https://github.com/rack/rack/issues/903","id":90426765,"number":903,"title":"\"EOFError: bad content body\" for multipart form requests","user":{"login":"rplopes","id":760760,"avatar_url":"https://avatars.githubusercontent.com/u/760760?v=3","gravatar_id":"","url":"https://api.github.com/users/rplopes","html_url":"https://github.com/rplopes","followers_url":"https://api.github.com/users/rplopes/followers","following_url":"https://api.github.com/users/rplopes/following{/other_user}","gists_url":"https://api.github.com/users/rplopes/gists{/gist_id}","starred_url":"https://api.github.com/users/rplopes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rplopes/subscriptions","organizations_url":"https://api.github.com/users/rplopes/orgs","repos_url":"https://api.github.com/users/rplopes/repos","events_url":"https://api.github.com/users/rplopes/events{/privacy}","received_events_url":"https://api.github.com/users/rplopes/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":17,"created_at":"2015-06-23T16:00:46Z","updated_at":"2016-07-21T01:58:57Z","closed_at":null,"body":"On a multipart form where users can submit profile information like a profile picture upload we're getting occasional \"EOFError: bad content body\" errors. They come mostly from mobile devices. These errors are being raised in 2 different parts of the code:\r\n\r\n - [`get_current_head_and_filename_and_content_type_and_name_and_body`](https://github.com/rack/rack/blob/8cb9b65b4e7c7157aba0f5421e59c70411c919cf/lib/rack/multipart/parser.rb#L147)\r\n - [`fast_forward_to_first_boundary`](https://github.com/rack/rack/blob/8cb9b65b4e7c7157aba0f5421e59c70411c919cf/lib/rack/multipart/parser.rb#L96) (happens after the other one has succeeded)\r\n\r\nThe errors are rare enough that they don't seem to be related to one particular setup. The fact that they happen mostly on mobile and in a form where users can upload profile pictures suggests that it might have to do with network issues, but that's as far as we can get.\r\n\r\nThis error gets reported to HoneyBadger, but it never reaches the Rails application code, so we never get to the controller and we can't rescue from it.\r\n\r\nThe closest we got to reproducing this was with a request like:\r\n\r\n```\r\ncurl 'http://localhost:3000/user' -H 'Content-Type: multipart/form-data; boundary=---------------------------6230707608200005481346647437' --data 'user[short_description]=A profile'\r\n```\r\n\r\nWhich in development returns an error page that includes:\r\n\r\n```\r\n  <h1 class=\"err\">Error starting application</h1>\r\n  <h2>Your Rack app raised an exception when Pow tried to run it.</h2>\r\n  <section>\r\n    <pre class=\"breakout small_text\"><strong>EOFError: bad content body</strong>\r\n~/.gem/ruby/2.1.6/gems/rack-1.6.4/lib/rack/multipart/parser.rb:97:in `block in fast_forward_to_first_boundary'\r\n~/.gem/ruby/2.1.6/gems/rack-1.6.4/lib/rack/multipart/parser.rb:95:in `loop'\r\n~/.gem/ruby/2.1.6/gems/rack-1.6.4/lib/rack/multipart/parser.rb:95:in `fast_forward_to_first_boundary'\r\n~/.gem/ruby/2.1.6/gems/rack-1.6.4/lib/rack/multipart/parser.rb:53:in `parse'\r\n~/.gem/ruby/2.1.6/gems/rack-1.6.4/lib/rack/multipart.rb:25:in `parse_multipart'\r\n<a href=\"#\" onclick=\"this.style.display='none',this.nextSibling.style.display='';return false\">Show 44 more lines</a><div style=\"display: none\">~/.gem/ruby/2.1.6/gems/rack-1.6.4/lib/rack/request.rb:375:in `parse_multipart'\r\n```\r\n\r\nIs there something we're overlooking? We'd expect our Rails app to at least return something like a 400 error instead of a 500."},"comment":{"url":"https://api.github.com/repos/rack/rack/issues/comments/234136233","html_url":"https://github.com/rack/rack/issues/903#issuecomment-234136233","issue_url":"https://api.github.com/repos/rack/rack/issues/903","id":234136233,"user":{"login":"carloshlopez","id":293378,"avatar_url":"https://avatars.githubusercontent.com/u/293378?v=3","gravatar_id":"","url":"https://api.github.com/users/carloshlopez","html_url":"https://github.com/carloshlopez","followers_url":"https://api.github.com/users/carloshlopez/followers","following_url":"https://api.github.com/users/carloshlopez/following{/other_user}","gists_url":"https://api.github.com/users/carloshlopez/gists{/gist_id}","starred_url":"https://api.github.com/users/carloshlopez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carloshlopez/subscriptions","organizations_url":"https://api.github.com/users/carloshlopez/orgs","repos_url":"https://api.github.com/users/carloshlopez/repos","events_url":"https://api.github.com/users/carloshlopez/events{/privacy}","received_events_url":"https://api.github.com/users/carloshlopez/received_events","type":"User","site_admin":false},"created_at":"2016-07-21T01:58:56Z","updated_at":"2016-07-21T01:58:56Z","body":"Andrew, does your code does work in unicorn?\n\nOn Wed, Jul 20, 2016, 2:35 AM Andrew N. Shalaev <notifications@github.com>\nwrote:\n\n> #=> env[\"CONTENT_TYPE\"] => \"multipart/form-data; boundary=abc\" - Its Bad\n>\n> I tried debug for this issue, and I found that this code can not find\n> first boundary in request body:\n>\n> https://github.com/rack/rack/blob/rack-1.3/lib/rack/multipart/parser.rb#L82\n>\n> —\n> You are receiving this because you commented.\n> Reply to this email directly, view it on GitHub\n> <https://github.com/rack/rack/issues/903#issuecomment-233866203>, or mute\n> the thread\n> <https://github.com/notifications/unsubscribe-auth/AAR6Albtqh4mSXztf9XH49fda6TN2ybAks5qXc-xgaJpZM4FJ_ib>\n> .\n>\n"}}
{"actor":{"display_login":"carloshlopez"}}