{"action":"opened","issue":{"url":"https://api.github.com/repos/travisbrown/circe/issues/217","repository_url":"https://api.github.com/repos/travisbrown/circe","labels_url":"https://api.github.com/repos/travisbrown/circe/issues/217/labels{/name}","comments_url":"https://api.github.com/repos/travisbrown/circe/issues/217/comments","events_url":"https://api.github.com/repos/travisbrown/circe/issues/217/events","html_url":"https://github.com/travisbrown/circe/issues/217","id":138204906,"number":217,"title":"decoding 'null' for a case class with only Option fields does not fail fast as expected","user":{"login":"longcao","id":865236,"avatar_url":"https://avatars.githubusercontent.com/u/865236?v=3","gravatar_id":"","url":"https://api.github.com/users/longcao","html_url":"https://github.com/longcao","followers_url":"https://api.github.com/users/longcao/followers","following_url":"https://api.github.com/users/longcao/following{/other_user}","gists_url":"https://api.github.com/users/longcao/gists{/gist_id}","starred_url":"https://api.github.com/users/longcao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/longcao/subscriptions","organizations_url":"https://api.github.com/users/longcao/orgs","repos_url":"https://api.github.com/users/longcao/repos","events_url":"https://api.github.com/users/longcao/events{/privacy}","received_events_url":"https://api.github.com/users/longcao/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-03-03T15:08:41Z","updated_at":"2016-03-03T15:08:41Z","closed_at":null,"body":"@ty707 and I found a bug with automatic decoding + derivation in which when decoding a `null` to a case class of only `Option` fields, it doesn't fail fast as expected - it succeeds and returns an instance of the case class where all of its fields are `None`.\r\n\r\nExample error was repro'd on master @ dee431a5cf364f4ed4cd113f494bfe84cc826f11.\r\n\r\nPasting my REPL session:\r\n\r\n```scala\r\nimport io.circe._\r\nimport io.circe.generic.auto._\r\nimport io.circe.literal._\r\nimport io.circe.parser._\r\nimport io.circe.syntax._\r\nimport cats.data.Xor\r\n\r\nscala> case class Container[T](data: T)\r\ndefined class Container\r\n\r\nscala> case class Item(a: Option[Int], b: Option[String])\r\ndefined class Item\r\n\r\n// I'd expect this to fail hard because data: T was improperly defined, since the \"data\" field is in fact nullable/optional\r\nscala> decode[Container[Item]](\"\"\"{\"data\":null}\"\"\")\r\nres0: cats.data.Xor[io.circe.Error,Container[Item]] = Right(Container(Item(None,None)))\r\n\r\n// I'd also expect this to fail hard\r\nscala> decode[Item](\"\"\"null\"\"\")\r\nres1: cats.data.Xor[io.circe.Error,Item] = Right(Item(None,None))\r\n\r\nscala> case class Qwer(a: Option[Int], b: String)\r\ndefined class Qwer\r\n\r\n// This seems to behave as expected, having a single non-Option field causes it to fail hard\r\nscala> decode[Qwer](\"\"\"null\"\"\")\r\nres2: cats.data.Xor[io.circe.Error,Qwer] = Left(io.circe.DecodingFailure: Attempt to decode value on failed cursor: El(DownField(b),false))\r\n```"}}