Skip to content

Commit

Permalink
Fixes #25 by validating 0 length files
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelsellers committed Jan 10, 2024
1 parent 6c33fdd commit 2f96015
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/GitHubCostVisualizer.Web/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public IActionResult Report(HomeViewModel data)
using (var csvData = new CsvReader(reader, CultureInfo.InvariantCulture))
{
var rawReport = csvData.GetRecords<GithubUsageEntry>().ToList();
if (rawReport.Count == 0)
{
ModelState.AddModelError(nameof(data.UploadFile), "The uploaded file did not contain any records, please try with a different file.");
return View(nameof(Index), data);
}
var model = _processor.ProcessUsageReport(rawReport);
return View(model);
}
Expand Down

0 comments on commit 2f96015

Please sign in to comment.