Skip to content

Empty response when JSON fails to deserialize #562

@idubrov

Description

@idubrov
  1. The version of Rocket you're using. Ensure it's the latest, if possible.

0.3.6

  1. The operating system (distribution and version) where the issue occurs.

Mac OS X Sierra 10.12.6 (16G1212)

  1. A brief description of the bug that includes:
  • The nature of the bug.

Connection is immediately closed if JSON being deserialized returns an error. The following log messages I think explain it well:

 WARN  rocket::data::data_stream > Data left unread. Force closing network stream.
 ERROR rocket_contrib::json      > Couldn't parse JSON body: ErrorImpl { code: Message("missing field `url`"), line: 1, column: 3244 }
 INFO  rocket::rocket            > Outcome: Failure
 WARN  rocket::rocket            > Responding with 400 Bad Request catcher.
 ERROR rocket::rocket            > Failed to write response: Error { repr: Os { code: 32, message: "Broken pipe" } }.
 INFO  hyper::server             > set_read_timeout keep_alive Error { repr: Os { code: 22, message: "Invalid argument" } }
  • When the bug occurs.

Client submits JSON request which fails to deserialize in rocket_contrib-0.3.6/src/json.rs:101

  • What you expected vs. what actually happened.

I expected 400 error to be returned. What I get is client receiving no response (connection is closed).

  1. How you uncovered the bug. Short, reproducible tests are especially useful.

Accidentally. Don't have test case at the moment.

  1. Ideas, if any, about what Rocket is doing incorrectly.

I think, Rocket should skip the remaining data when deserialization fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    deficiencySomething doesn't work as well as it could

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions