kitodo-production icon indicating copy to clipboard operation
kitodo-production copied to clipboard

NPE while creating Import Configuration

Open henning-gerhardt opened this issue 2 years ago • 3 comments

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)

henning-gerhardt avatar May 02 '23 09:05 henning-gerhardt

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

BartChris avatar Aug 18 '23 12:08 BartChris

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?

solth avatar May 06 '24 07:05 solth

@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

BartChris avatar May 06 '24 11:05 BartChris