kitodo / kitodo-production

Kitodo.Production is a workflow management tool for mass digitization and is part of the Kitodo Digital Library Suite.
http://www.kitodo.org/software/kitodoproduction/
GNU General Public License v3.0
58 stars 65 forks source link

NPE while creating Import Configuration #5647

Open henning-gerhardt opened 1 year ago

henning-gerhardt commented 1 year ago

Describe the bug Creating a new import configuration can cause a null pointer exception like

java.lang.NullPointerException
    at java.base/java.lang.String.contains(String.java:2036)
    at org.kitodo.production.helper.Helper.appendUnusedInsertions(Helper.java:493)
    at org.kitodo.production.helper.Helper.getTranslation(Helper.java:479)
    at org.kitodo.production.forms.validators.ImportConfigurationMappingValidator.validate(ImportConfigurationMappingValidator.java:60)
    at org.kitodo.production.forms.validators.ImportConfigurationMappingValidator.validate(ImportConfigurationMappingValidator.java:30)
    at javax.faces.component._ComponentUtils.callValidators(_ComponentUtils.java:291)
    at javax.faces.component.UIInput.validateValue(UIInput.java:489)
    at org.primefaces.component.picklist.PickList.validateValue(PickList.java:116)
    at javax.faces.component.UIInput.validate(UIInput.java:746)
    at org.primefaces.component.picklist.PickList.validate(PickList.java:182)
    at javax.faces.component.UIInput.processValidators(UIInput.java:293)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1458)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1458)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1458)
    at org.primefaces.util.ComponentUtils.processValidatorsOfFacetsAndChilds(ComponentUtils.java:247)
    at org.primefaces.component.api.UITabPanel.processValidators(UITabPanel.java:1107)
    at javax.faces.component.UIForm.processValidators(UIForm.java:210)

To Reproduce Steps to reproduce the behavior:

  1. Create new Import configuration
  2. Insert somthing for title and description field
  3. Select Fileupload as Configuration type
  4. Click on Save Button
  5. Get the null pointer exception

Expected behavior In case of a configuration error an error message should appear and not a null pointer exception

Release 3.6.0-SNAPSHOT (master branch from March 1th 2023 commit 5b60965afb8a9512b0021b416ad98291971e66a4)

BartChris commented 10 months ago

This happens if nothing is selected for "Metadata format of upload file". Even if it appears like MODS is selected here, the selected value is NULL until one selects a value by hand. image

This leads to metadaformat being NULL here: https://github.com/kitodo/kitodo-production/blob/3f6010fb0a4369570d624bf500d3cd452ea1e204/Kitodo/src/main/java/org/kitodo/production/forms/validators/ImportConfigurationMappingValidator.java#L58

solth commented 2 months ago

I think this has been resolved in the current master branch. Configuring an ImportConfiguration of type FileUpload without explicitely setting a metadata format still does not correctly set the displayed default value "MODS" in the background, but the exception is handled in the form validation and displays a proper error message (instead of an unhandled stack trace):

Bildschirmfoto 2024-05-06 um 09 45 46

(it should save the configuration successfully since MODS appears to be selected, though)

@henning-gerhardt & @BartChris can you confirm this?

BartChris commented 2 months ago

@solth I can confirm that the message is now displayed and no stack trace is shown, so the situation is improved in Master. However, the German translation for the message is missing: https://github.com/kitodo/kitodo-production/blob/ca015ec490301b52471d91fd513b891b2ea95950/Kitodo/src/main/resources/messages/messages_de.properties#L639