Check issue key when downloading (#56)
diff --git a/migration/src/download_jira.py b/migration/src/download_jira.py
index 9fb5c04..13c8f8c 100644
--- a/migration/src/download_jira.py
+++ b/migration/src/download_jira.py
@@ -41,9 +41,16 @@
if res.status_code != 200:
logger.warning(f"Can't download {issue_id}. status code={res.status_code}, message={res.text}")
return False
+ data = res.json()
+ if "key" not in data:
+ logger.warning(f"The issue's key does not exist. Skipped {issue_id}")
+ return False
+ if data["key"] != issue_id:
+ logger.warning(f"The issue key {data['key']} does not match the request key {issue_id}. Maybe this was moved.")
+ return False
dump_file = jira_dump_file(dump_dir, num)
with open(dump_file, "w") as fp:
- json.dump(res.json(), fp, indent=2)
+ json.dump(data, fp, indent=2)
logger.debug(f"Jira issue {issue_id} was downloaded in {dump_file}.")
return True