Page MenuHomeSoftware Heritage

Make content_add validate its input using swh-model.
ClosedPublic

Authored by vlorentz on Aug 19 2019, 2:45 PM.

Details

Summary

The initial goal of this commit was to make the in-mem content_add raise
errors on input that would make postgresql error.

As a side-effect, the pgsql content_add now validate its input as well,
so clients get a nice/meaningful error instead of postgresql's error.

I'm planning on adding similar validation to other *_add methods.

Depends on D1864 (same repo), and D1860, D1861, D1862, D1863 (swh-model)

Diff Detail

Repository
rDSTO Storage manager
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

vlorentz retitled this revision from Make content_add validate its input. to Make content_add validate its input using swh-model..Aug 19 2019, 2:52 PM

Use from_dict instead of constructor.

  • really use from_dict instead of constructor
  • update required swh-model version.
  • remove useless deepcopies

Make postgresql validate itself when possible. (Depends on D1872 for the tests.)

ardumont added a subscriber: ardumont.

Looks good.

But _filter_new_content is no longer a filter.
It normalizes and validates the content dict.
So that needs a rename.

Also the internal methods need docstrings to add details on what's what (and also to make sure we do not diverge in the future for any unforeseen reasons).

Cheers,

This revision now requires changes to proceed.Aug 26 2019, 4:23 PM
  • move normalization and validation out of the 'filter' function
  • docstrings
olasd added inline comments.
swh/storage/storage.py
107

@staticmethod?

118

@staticmethod as well?

This revision is now accepted and ready to land.Aug 29 2019, 10:13 AM
This revision was landed with ongoing or failed builds.Aug 29 2019, 11:32 AM
This revision was automatically updated to reflect the committed changes.