Bug 993450 - Unhandled exception: Long file and path names can cause a path validation exception
Unhandled exception: Long file and path names can cause a path validation exc...
Status: CLOSED UPSTREAM
Product: Zanata
Classification: Community
Component: Component-Logic (Show other bugs)
development
Unspecified Unspecified
medium Severity medium
: ---
: ---
Assigned To: Michelle Kim
Zanata-QA Mailling List
: screened
Depends On:
Blocks: 994362
  Show dependency treegraph
 
Reported: 2013-08-05 20:41 EDT by Damian Jansen
Modified: 2015-07-28 23:35 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-07-28 23:35:04 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Damian Jansen 2013-08-05 20:41:49 EDT
Description of problem:
A filename can be 255 characters. However the app assumes that the path concat filename is up to 255 characters, so if a user tries to upload a long filename  to a long path an exception occurs.

Version-Release number of selected component (if applicable):
Dev

How reproducible:
Easy always

Steps to Reproduce:
1. Create a file with 255 character filename
2. Sign in as admin / maintainer
3. Go to a Project, Project Version
4. Press Source Documents, select Upload Document
5. Select the long filename file
6. Enter a path of "a"

Actual results:
Exception

Expected results:
A "You can't do that" message, or just allow text for a path (assuming a url for the document can handle the string length)

Additional info:
List of constraint violations:[
        ConstraintViolationImpl{interpolatedMessage='size must be between 0 and 255', propertyPath=docId, rootBeanClass=class org.zanata.model.HDocument, messageTemplate='{javax.validation.constrai
nts.Size.message}'}
]: javax.faces.FacesException: #{projectIterationFilesAction.uploadDocumentFile}: javax.validation.ConstraintViolationException: Validation failed for classes [org.zanata.model.HDocument] during pe
rsist time for groups [javax.validation.groups.Default, ]
List of constraint violations:[
        ConstraintViolationImpl{interpolatedMessage='size must be between 0 and 255', propertyPath=docId, rootBeanClass=class org.zanata.model.HDocument, messageTemplate='{javax.validation.constraints.Size.message}'}
]
Comment 1 David Mason 2015-03-25 22:43:08 EDT
The error message at the moment does not provide enough information for users to know what has gone wrong. It is just "Failed to upload this file."

There are several stages we can use to improve user experience around this:

1. Ensure that the error message when this happens indicates that the path+filename length is too great. At this stage the error would still only show after the user has attempted to initiate upload.

2. Add a check in the dialog that will display an error message and disable the upload button whenever the length of path + any filename in the list is greater than 255.

3. Increase the limit on path+filename length. Considerations for determining a sensible limit:

 - what URL length can be handled by typical user agents (browsers etc.)?
 - what path+filename length can supported operating systems handle?


Some research about path and filename lengths on operating systems indicates that a limit of 255 characters is sensible for the filename on its own, but the limit on total path+filename length could be set as high as 4096 without causing problems on typical Linux systems, and as high as 32k for Windows systems (as long as individual path components should are limited to 255 characters).
There is a lot of complexity in this area, so there is no simple solution that will work everywhere. Owncloud use an interesting solution, where clients check that paths are valid for the file system, and for paths that cannot be used they alias the original path to a locally valid path. 

   see: Cross Platform File Handling | owncloud/core : https://github.com/owncloud/core/wiki/Cross-Platform-File-Handling


For browsers, a sensible URL length limit is 2000 characters. Since path is used in some of our REST URLs, a limit of 1450 characters or so might be sensible to allow for project and version slug length and other URL components. The other option would be to use something more constrained than path+filename as the REST URL for a document. This would require adjustment to how all the clients use the REST interface, and would probably increase the required number of REST calls since some metadata would be needed to find the id of a document based on its path and filename.

    see: Top answer: What is the maximum length of a URL in different browsers? http://stackoverflow.com/a/417184/297938
Comment 2 David Mason 2015-03-25 22:50:50 EDT
Michelle, I think we should look at implementing step 1. and 2. from the previous comment soon, since they will not take much effort.

Step 3 is a lot more complicated, but I think is something we have to address in the long-term. At the moment we are putting too much restriction on filename+path length, so there are many projects in the world that just will not work with Zanata. This will cause more problems as usage of Zanata expands. Even if we just increase the path length limit to 1450 characters, I think it would greatly reduce the amount of projects that cannot work on Zanata.
Comment 3 Michelle Kim 2015-04-06 19:35:19 EDT
Hi David,
Let's bring this up to our backlog grooming meeting to discuss the possible solutions. I am moving this bug to higher in the backlog for discussion.
Thanks Michelle
Comment 4 Zanata Migrator 2015-07-28 23:35:04 EDT
Migrated; check JIRA for bug status: http://zanata.atlassian.net/browse/ZNTA-333

Note You need to log in before you can comment on or make changes to this bug.