From 62dc8270b66b8af40c4405d217d6559bdeb0e666 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 20 May 2021 14:39:33 -0700 Subject: [PATCH] Catch unexpectedly missing columns in csv imports I kept the 500 error here so that things don't silently fail in unexepcted ways --- bookwyrm/views/import_data.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bookwyrm/views/import_data.py b/bookwyrm/views/import_data.py index 2bbb5947..910283c4 100644 --- a/bookwyrm/views/import_data.py +++ b/bookwyrm/views/import_data.py @@ -7,6 +7,7 @@ from django.http import HttpResponseBadRequest from django.shortcuts import get_object_or_404, redirect from django.template.response import TemplateResponse from django.utils.decorators import method_decorator +from django.utils.translation import gettext_lazy as _ from django.views import View from bookwyrm import forms, models @@ -62,8 +63,8 @@ class Import(View): include_reviews, privacy, ) - except (UnicodeDecodeError, ValueError): - return HttpResponseBadRequest("Not a valid csv file") + except (UnicodeDecodeError, ValueError, KeyError): + return HttpResponseBadRequest(_("Not a valid csv file")) importer.start_import(job)