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 Metadata indexer
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

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 ๐Ÿ˜ˆ

This revision was automatically updated to reflect the committed changes.