inception-project / inception

INCEpTION provides a semantic annotation platform offering intelligent annotation assistance and knowledge management.
https://inception-project.github.io
Apache License 2.0
596 stars 152 forks source link

Unable to upload file for particular "name" body parameter in upload URL #4606

Open 77neel opened 8 months ago

77neel commented 8 months ago

Describe the bug upload fails due to file name name pattern is like: AAAAAA_ Bbbbbbb AAA ECD System Data Assessment _INDIA_ JO

With same named file or different named files uploaded with this "name" body parameter it fails for all and on changing the "name" value, it get uploaded.

error :

{
    "messages": [
        {
            "level": "ERROR",
            "message": "Internal server error: Unable to create CAS: null"
        }
    ]
}

To Reproduce Steps to reproduce the behavior:

  1. Try to hit create document URL https://{{domain-name}}/api/aero/v1/projects/{{project-id}}/documents with need body parameter and "name" parameter must be above method

Expected behavior File should get uploaded and document should be created against provided project.

Screenshots createDocumentIssue

Please complete the following information:

77neel commented 8 months ago

Additional Finding :

When that file upload with method name using Inception document upload UI, it give error:

On UI bottom notification toast :

Error while uploading document [AAAAAA_ Bbbbbbb AAA ECD System Data Assessment _INDIA_ JO.pdf]:
 URISyntaxException: Illegal character in path at index 87:
 file:/C:/Users/admin-1234/.inception/repository/project/20/document/12/source/AAAAAA_ Bbbbbbb%20AAA%20ECD%20System%20Data%20Assessment%20_INDIA_%20JO.pdf

While Debuging, In catch block :

org.springframework.core.NestedIOException: Invalid URI
 [file:/C:/Users/admin-1234/.inception/repository/project/20/document/17/source/AAAAAA_ Bbbbbbb AAA ECD System Data Assessment _INDIA_ JO.pdf]; nested exception is java.net.URISyntaxException: Illegal character in path at index 87: 
file:/C:/Users/admin-1234/.inception/repository/project/20/document/17/source/AAAAAA_ Bbbbbbb%20AAA%20ECD%20System%20Data%20Assessment%20_INDIA_%20JO.pdf 

ErrorStack.txt

Thing to notice : Here it not replacing space with %20 in path after character "AAAAAA Bb"_

Note : Name of file has been changed, due security reason but pattern of file name is maintained.

77neel commented 8 months ago

This issue is generated due to non-printable character (NBSP) in file name.

nonpritable-character

Able to resolve it by replacing it

reckart commented 7 months ago

Looks like something that needs to be fixed in DKPro Core.

Caused by: java.net.URISyntaxException: Illegal character in path at index 99: file:/.../file-with- -nbsp.txt
    at java.base/java.net.URI$Parser.fail(URI.java:2974) ~[?:?]
    at java.base/java.net.URI$Parser.checkChars(URI.java:3145) ~[?:?]
    at java.base/java.net.URI$Parser.parseHierarchical(URI.java:3227) ~[?:?]
    at java.base/java.net.URI$Parser.parse(URI.java:3175) ~[?:?]
    at java.base/java.net.URI.<init>(URI.java:623) ~[?:?]
    at org.springframework.util.ResourceUtils.toURI(ResourceUtils.java:381) ~[spring-core-5.3.32.jar:5.3.32]
    at org.springframework.util.ResourceUtils.toURI(ResourceUtils.java:370) ~[spring-core-5.3.32.jar:5.3.32]
    at org.springframework.core.io.AbstractResource.getURI(AbstractResource.java:125) ~[spring-core-5.3.32.jar:5.3.32]
    at org.springframework.core.io.UrlResource.getURI(UrlResource.java:216) ~[spring-core-5.3.32.jar:5.3.32]
    at org.dkpro.core.api.io.ResourceCollectionReaderBase.scan(ResourceCollectionReaderBase.java:527) ~[dkpro-core-api-io-asl-2.4.0.jar:?]
    at org.dkpro.core.api.io.ResourceCollectionReaderBase.initialize(ResourceCollectionReaderBase.java:241) ~[dkpro-core-api-io-asl-2.4.0.jar:?]
    at org.apache.uima.fit.component.CasCollectionReader_ImplBase.initialize(CasCollectionReader_ImplBase.java:41) ~[uimafit-core-3.5.0.jar:?]
    at org.apache.uima.collection.CollectionReader_ImplBase.initialize(CollectionReader_ImplBase.java:64) ~[uimaj-core-3.5.0.jar:?]
    at org.apache.uima.impl.CollectionReaderFactory_impl.produceResource(CollectionReaderFactory_impl.java:93) ~[uimaj-core-3.5.0.jar:?]
    at org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(CompositeResourceFactory_impl.java:64) ~[uimaj-core-3.5.0.jar:?]
    at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:284) ~[uimaj-core-3.5.0.jar:?]
    at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:334) ~[uimaj-core-3.5.0.jar:?]
    at org.apache.uima.UIMAFramework.produceCollectionReader(UIMAFramework.java:805) ~[uimaj-core-3.5.0.jar:?]
    at org.apache.uima.fit.factory.CollectionReaderFactory.createReader(CollectionReaderFactory.java:423) ~[uimafit-core-3.5.0.jar:?]
    at de.tudarmstadt.ukp.clarin.webanno.api.format.FormatSupport.read(FormatSupport.java:180) ~[classes/:?]
    at de.tudarmstadt.ukp.inception.export.DocumentImportExportServiceImpl.importCasFromFileNoChecks(DocumentImportExportServiceImpl.java:334) ~[classes/:?]
    at de.tudarmstadt.ukp.inception.export.DocumentImportExportServiceImpl.importCasFromFileNoChecks(DocumentImportExportServiceImpl.java:314) ~[classes/:?]
    at de.tudarmstadt.ukp.inception.export.DocumentImportExportServiceImpl$$FastClassBySpringCGLIB$$6bf689d0.invoke(<generated>) ~[classes/:?]
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.32.jar:5.3.32]
    at org.springframework.aop.framework.CglibAopProxy.invokeMethod(CglibAopProxy.java:386) ~[spring-aop-5.3.32.jar:5.3.32]
    at org.springframework.aop.framework.CglibAopProxy.access$000(CglibAopProxy.java:85) ~[spring-aop-5.3.32.jar:5.3.32]
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:703) ~[spring-aop-5.3.32.jar:5.3.32]
    at de.tudarmstadt.ukp.inception.export.DocumentImportExportServiceImpl$$EnhancerBySpringCGLIB$$5a9d5f27.importCasFromFileNoChecks(<generated>) ~[classes/:?]
    at de.tudarmstadt.ukp.inception.documents.DocumentServiceImpl.lambda$4(DocumentServiceImpl.java:815) ~[classes/:?]
    ... 149 more