Skip to content

Commit

Permalink
Merge pull request #2346 from rhelmer/bug1065071-ignore-unrecognizabl…
Browse files Browse the repository at this point in the history
…e-JSON-files

fix bug 1065071 - ignore unrecognizable JSON files
  • Loading branch information
rhelmer committed Sep 9, 2014
2 parents fe30e98 + 7458592 commit 07fd0ac
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
19 changes: 15 additions & 4 deletions socorro/cron/jobs/ftpscraper.py
Expand Up @@ -93,10 +93,21 @@ def parseBuildJsonFile(url, nightly=False):
if content:
try:
kvpairs = json.loads(content)
kvpairs['repository'] = kvpairs['moz_source_repo']\
.split('/', -1)[-1]
kvpairs['build_type'] = kvpairs['moz_update_channel']
kvpairs['buildID'] = kvpairs['buildid']
kvpairs['repository'] = kvpairs.get('moz_source_repo')
if kvpairs['repository']:
kvpairs['repository'] = kvpairs['repository']\
.split('/', -1)[-1]
kvpairs['build_type'] = kvpairs.get('moz_update_channel')
kvpairs['buildID'] = kvpairs.get('buildid')

# bug 1065071 - ignore JSON files that have keys with
# missing values.
if None in kvpairs.values():
# TODO - we need to refactor this code so we can
# use `config.logger` here.
# Then we can debug log invalid JSON.
print 'warning, unsupported JSON file: %s' % url
pass

return kvpairs
# bug 963431 - it is valid to have an empty file
Expand Down
10 changes: 10 additions & 0 deletions socorro/unittest/cron/jobs/test_ftpscraper.py
Expand Up @@ -971,6 +971,8 @@ def mocked_urlopener(url, today=None):
'build1/linux-i686/en-US/'):
return html_wrap % """
<a href="firefox-10.0b4.json">firefox-10.0b4.json</a>
<a href="firefox-10.0b4.en-US.linux-i686.mozinfo.json">
firefox-10.0b4.en-US.linux-i686.mozinfo.json</a>
"""
if url.endswith('/firefox/candidates/None-candidates/'
'build1/linux-i686/en-US/'):
Expand Down Expand Up @@ -1007,6 +1009,14 @@ def mocked_urlopener(url, today=None):
"moz_update_channel": "beta"
}
"""
# Ignore unrecognized JSON files, see bug 1065071
if 'firefox-10.0b4.en-US.linux-i686.mozinfo.json' in url:
return """
{
"something": "unexpected",
"nothing": "else"
}
"""
# Nightly tests for nightly and aurora builds
if url.endswith('/firefox/nightly/'):
return html_wrap % """
Expand Down

0 comments on commit 07fd0ac

Please sign in to comment.