Page MenuHomeSoftware Heritage

Prevent repository normalization from crashing on malformed input.
ClosedPublic

Authored by vlorentz on Jan 15 2019, 3:57 PM.

Diff Detail

Repository
rDCIDX Object indexer
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

vlorentz created this revision.Jan 15 2019, 3:57 PM
ardumont accepted this revision.Jan 15 2019, 4:57 PM
This revision is now accepted and ready to land.Jan 15 2019, 4:57 PM
douardda added inline comments.
swh/indexer/metadata_dictionary.py
287–296

I find this code a bit bloated.

Is it possible to have something other than a str or None for these values? (url, group and artifact) ?

Isn't this code enough?

if 'url' not in repo or repo.get('layout', 'default') != 'default':
    return
group_id = d.get('groupId', '')
artifact_id = d.get('artifactId', '')
url = os.path.join(repo['url'], group_id.replace('.', '/'), artifact_id)
return {'@id': url}

Hard to tell since it seems this method has no unit test 😈

vlorentz updated this revision to Diff 3022.Jan 15 2019, 5:02 PM
  • rebase
This revision was automatically updated to reflect the committed changes.