Bug 1630048 - Fix visual metrics encoding failures. r=perftest-reviewers,Bebe

This patch fixes a failure with encodings when opening JSONs. It changes the file opening portion to ignore these types of errors - they are occuring because of the different language being used. We have no need for this data so we can safely ignore them. One other change that is being done here is adding additional error logging because it was possible to lose an error stack trace.

Differential Revision: https://phabricator.services.mozilla.com/D70939
This commit is contained in:
Gregory Mierzwinski 2020-04-23 09:58:35 +00:00
parent f9253cf629
commit 44c8293525

View File

@ -154,13 +154,13 @@ def read_json(json_path, schema):
The contents of the file at ``json_path`` interpreted as JSON.
"""
try:
with open(str(json_path), "r") as f:
with open(str(json_path), "r", encoding="utf-8", errors="ignore") as f:
data = json.load(f)
except Exception:
log.error("Could not read JSON file", path=json_path, exc_info=True)
raise
log.info("Loaded JSON from file", path=json_path, read_json=data)
log.info("Loaded JSON from file", path=json_path)
try:
schema(data)
@ -204,7 +204,7 @@ def main(log, args):
log.error(
"Could not read extract browsertime results archive",
path=browsertime_results_path,
exc_info=True,
exc_info=True
)
return 1
log.info("Extracted browsertime results", path=browsertime_results_path)
@ -213,6 +213,11 @@ def main(log, args):
jobs_json_path = fetch_dir / "browsertime-results" / "jobs.json"
jobs_json = read_json(jobs_json_path, JOB_SCHEMA)
except Exception:
log.error(
"Could not open the jobs.json file",
path=jobs_json_path,
exc_info=True
)
return 1
jobs = []
@ -223,6 +228,11 @@ def main(log, args):
try:
browsertime_json = read_json(browsertime_json_path, BROWSERTIME_SCHEMA)
except Exception:
log.error(
"Could not open a browsertime.json file",
path=browsertime_json_path,
exc_info=True
)
return 1
for site in browsertime_json: