zimeon / ocfl-py

OCFL tools in Python
MIT License
20 stars 6 forks source link

Improve error reporting for the case of bad digestAlgorithm #56

Open zimeon opened 3 years ago

zimeon commented 3 years ago

See https://github.com/OCFL/fixtures/pull/85

Use of E039 should probably be another E025 error.

Want to tidy up all sorts of confusing errors caused because validator rejects md5 and then carries on with sha512 as the default for other checks:

(py38) simeon@RottenApple fixtures> ../ocfl-validate.py 1.0/bad-objects/E025_E001_wrong_digest_algorithm/
[E025a] OCFL Object root inventory manifest block includes a digest (d2c79c8519af858fac2993c2373b5203) that doesn't have the correct form for the sha512 algorithm (see https://ocfl.io/1.0/spec/#E025)
[E025a] OCFL Object root inventory manifest block includes a digest (fccd3f96d461f495a3bef31dc1d28f01) that doesn't have the correct form for the sha512 algorithm (see https://ocfl.io/1.0/spec/#E025)
[E039] OCFL Object root inventory `digestAlgorithm` attribute not an allowed value (got 'md5') (see https://ocfl.io/1.0/spec/#E039)
[E050d] OCFL Object root inventory v1 version state block includes a bad digest (d2c79c8519af858fac2993c2373b5203) (see https://ocfl.io/1.0/spec/#E050)
[E050d] OCFL Object root inventory v1 version state block includes a bad digest (fccd3f96d461f495a3bef31dc1d28f01) (see https://ocfl.io/1.0/spec/#E050)
[E058a] OCFL Object root inventory is missing sidecar digest file at inventory.json.sha512 (see https://ocfl.io/1.0/spec/#E058)
INFO:ocfl.object:OCFL object at 1.0/bad-objects/E025_E001_wrong_digest_algorithm/ is INVALID

Either the validator should short-circuit at finding a bad digestAlgorithm or else make other checks more about consistency given a disallowed algorithm.