Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE is thrown when validating a bag against a BagIt profile #136

Open
sprater opened this issue Dec 30, 2019 · 2 comments
Open

NPE is thrown when validating a bag against a BagIt profile #136

sprater opened this issue Dec 30, 2019 · 2 comments

Comments

@sprater
Copy link

sprater commented Dec 30, 2019

bagit-java version: 5.2.0
Operating System CentOS (Linux) 7

A null pointer exception is thrown when I attempt to validate a bag against a BagIt 1.3.0 profile without a Manifests-Required block. Looking at the class BagitProfileDeserializer (https://github.com/LibraryOfCongress/bagit-java/blob/5.2.0/src/main/java/gov/loc/repository/bagit/conformance/profile/BagitProfileDeserializer.java), it looks like all the parse* methods will throw NPEs in their for loops if the parsed block does not exist in the profile.

As I read the latest BagIt profile spec 1.3.0 (https://bagit-profiles.github.io/bagit-profiles-specification/), none of the blocks that throw NPEs if missing are required to be in a profile.

Given

  • I have a BagIt profile without a "Manfests-Required" block
  • And I have a Bag that references this profile

When

  • I validate the Bag against the profile

Then

  • The Bag should validate.

Log output:

$ java -jar target/bagmanager.jar verify --with-profile /var/tmp/testbag1
Verifying valid bag from contents at '/var/tmp/testbag1'
Verifying conformance to BagIt profile
Bag is not valid
java.lang.NullPointerException: null
        at gov.loc.repository.bagit.conformance.profile.BagitProfileDeserializer.parseManifestTypesRequired(BagitProfileDeserializer.java:128)
        at gov.loc.repository.bagit.conformance.profile.BagitProfileDeserializer.deserialize(BagitProfileDeserializer.java:47)
        at gov.loc.repository.bagit.conformance.profile.BagitProfileDeserializer.deserialize(BagitProfileDeserializer.java:24)
        at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4011)
        at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3058)
        at gov.loc.repository.bagit.conformance.BagProfileChecker.parseBagitProfile(BagProfileChecker.java:95)
        at gov.loc.repository.bagit.conformance.BagProfileChecker.bagConformsToProfile(BagProfileChecker.java:73)
[...]

bagit-profile-sample-v1_0_json.txt

@jscancella
Copy link
Contributor

@sprater I don't think this library is maintained anymore. Feel free to submit to my maintained fork of this library at https://github.com/jscancella/bagging

@sprater
Copy link
Author

sprater commented Dec 31, 2019

Will do, thanks @jscancella.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants