enonic / xp

Enonic XP
https://enonic.com
GNU General Public License v3.0
202 stars 34 forks source link

Invalid input type for AttachmentUpload #5776

Closed aro closed 6 years ago

aro commented 7 years ago

Steps to reproduce issue:

The problem is that AttachmentUploaderType uses Reference as underlying type. When trying to convert from the JavaScript string type to a Reference it fails because a Reference is a wrapper for a NodeId, and NodeId allows a limited set of characters.

Is it correct that AttachmentUpload is based on a Reference? Shouldn't it have been BinaryReference?

This was reported in Discuss: https://discuss.enonic.com/t/unable-to-edit-object-with-attachment-with-content-modify/1285

Stack trace:

Caused by: com.enonic.xp.data.ValueTypeException: Value of type [java.lang.String] cannot be converted to [Reference]: NodeId format incorrect: Screenshot from 2017-10-03 15-29-40.png
    at com.enonic.xp.data.ValueType.convertError(ValueType.java:92)
    at com.enonic.xp.data.ValueType.convert(ValueType.java:74)
    at com.enonic.xp.data.Value.asReference(Value.java:193)
    at com.enonic.xp.inputtype.AttachmentUploaderType.createValue(AttachmentUploaderType.java:21)
    at com.enonic.xp.lib.common.FormJsonToPropertyTreeTranslator.mapValue(FormJsonToPropertyTreeTranslator.java:96)
    at com.enonic.xp.lib.common.FormJsonToPropertyTreeTranslator.addValue(FormJsonToPropertyTreeTranslator.java:74)
    at com.enonic.xp.lib.common.FormJsonToPropertyTreeTranslator.lambda$addValue$0(FormJsonToPropertyTreeTranslator.java:70)
    at java.util.Iterator.forEachRemaining(Iterator.java:116)
    at com.enonic.xp.lib.common.FormJsonToPropertyTreeTranslator.addValue(FormJsonToPropertyTreeTranslator.java:70)
    at com.enonic.xp.lib.common.FormJsonToPropertyTreeTranslator.traverse(FormJsonToPropertyTreeTranslator.java:54)
    at com.enonic.xp.lib.common.FormJsonToPropertyTreeTranslator.translate(FormJsonToPropertyTreeTranslator.java:43)
    at com.enonic.xp.lib.content.BaseContextHandler.translateToPropertyTree(BaseContextHandler.java:76)
    at com.enonic.xp.lib.content.ModifyContentHandler.createPropertyTree(ModifyContentHandler.java:157)
    at com.enonic.xp.lib.content.ModifyContentHandler.updateContent(ModifyContentHandler.java:103)
    at com.enonic.xp.lib.content.ModifyContentHandler.lambda$newContentEditor$0(ModifyContentHandler.java:81)
navyhod commented 6 years ago

Hi ! Is there any news about this bug ?

aro commented 6 years ago

Hi @navyhod The issue has been fixed and it will be included in 6.13 release. It's available in the latest snapshot from XP, in the master branch. But that is not stable, and must not be used in production.