{"action":"created","issue":{"url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/601","repository_url":"https://api.github.com/repos/JoshClose/CsvHelper","labels_url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/601/labels{/name}","comments_url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/601/comments","events_url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/601/events","html_url":"https://github.com/JoshClose/CsvHelper/issues/601","id":187738328,"number":601,"title":"No exception thrown if csv file has no record but header doesn't match map","user":{"login":"mayerwin","id":2272127,"avatar_url":"https://avatars.githubusercontent.com/u/2272127?v=3","gravatar_id":"","url":"https://api.github.com/users/mayerwin","html_url":"https://github.com/mayerwin","followers_url":"https://api.github.com/users/mayerwin/followers","following_url":"https://api.github.com/users/mayerwin/following{/other_user}","gists_url":"https://api.github.com/users/mayerwin/gists{/gist_id}","starred_url":"https://api.github.com/users/mayerwin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mayerwin/subscriptions","organizations_url":"https://api.github.com/users/mayerwin/orgs","repos_url":"https://api.github.com/users/mayerwin/repos","events_url":"https://api.github.com/users/mayerwin/events{/privacy}","received_events_url":"https://api.github.com/users/mayerwin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-07T15:18:06Z","updated_at":"2016-12-14T14:33:36Z","closed_at":null,"body":"I was rather surprised to see that CsvHelper would not throw an exception when reading a file which, instead of the usual CSV, was just a single line of error code (the file could not be generated), even though a proper ClassMap is registered.\r\nI tried setting ThrowOnBadData to true, but it does not help the header fields get validated against the ClassMap.\r\n\r\nThis can cause serious issues when a CSV file has no record because something wrong happened. It looks like a bug, unless I am missing a configuration setting.\r\n\r\nI am using the following code:\r\n\r\n```\r\n using (var csv = new CsvReader(new StringReader(\"Something terrible happened\"), new CsvConfiguration { CultureInfo = CultureInfo.InvariantCulture, ThrowOnBadData = true, Delimiter = \"|\", ShouldSkipRecord = cols => string.IsNullOrWhiteSpace(string.Join(\"\", cols)) })) {\r\n  csv.Configuration.RegisterClassMap<Activity.Map>();\r\n  return csv.GetRecords<Activity>();\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/comments/267048539","html_url":"https://github.com/JoshClose/CsvHelper/issues/601#issuecomment-267048539","issue_url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/601","id":267048539,"user":{"login":"Arithmomaniac","id":654897,"avatar_url":"https://avatars.githubusercontent.com/u/654897?v=3","gravatar_id":"","url":"https://api.github.com/users/Arithmomaniac","html_url":"https://github.com/Arithmomaniac","followers_url":"https://api.github.com/users/Arithmomaniac/followers","following_url":"https://api.github.com/users/Arithmomaniac/following{/other_user}","gists_url":"https://api.github.com/users/Arithmomaniac/gists{/gist_id}","starred_url":"https://api.github.com/users/Arithmomaniac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Arithmomaniac/subscriptions","organizations_url":"https://api.github.com/users/Arithmomaniac/orgs","repos_url":"https://api.github.com/users/Arithmomaniac/repos","events_url":"https://api.github.com/users/Arithmomaniac/events{/privacy}","received_events_url":"https://api.github.com/users/Arithmomaniac/received_events","type":"User","site_admin":false},"created_at":"2016-12-14T14:33:36Z","updated_at":"2016-12-14T14:33:36Z","body":"Looks like the upcoming `ReadHeader` method will enable solving this problem: [https://github.com/JoshClose/CsvHelper/commit/68712c688603b527731cd45262614c4057e63426](url)"}}
{"actor":{"display_login":"Arithmomaniac"}}