From e70f7fa706fa7fc851fcb67f0bb17c114b9f8749 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Mon, 6 Jul 2020 22:54:49 +0530 Subject: [PATCH] fix: Show message if URL without gid is errored --- frappe/utils/csvutils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frappe/utils/csvutils.py b/frappe/utils/csvutils.py index f73f80582a..9bda61ee8d 100644 --- a/frappe/utils/csvutils.py +++ b/frappe/utils/csvutils.py @@ -191,7 +191,6 @@ def get_csv_content_from_google_sheets(url): 'Accept': 'text/csv' } response = requests.get(url, headers=headers) - response.raise_for_status() if response.ok: # if it returns html, it couldn't find the CSV content @@ -202,6 +201,11 @@ def get_csv_content_from_google_sheets(url): title=_("Invalid URL") ) return response.content + elif response.status_code == 400: + frappe.throw(_('Google Sheets URL must end with "gid={number}". Copy and paste the URL from the browser address bar and try again.'), + title=_("Incorrect URL")) + else: + response.raise_for_status() def validate_google_sheets_url(url): if "docs.google.com/spreadsheets" not in url: