You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Burton Rhodes <bu...@gmail.com> on 2024/02/05 15:51:14 UTC

[7.0.0-M3] Error message

When catching a FileUploadException in the 
AbstractMultiPartRequest.parse() method, if the final "else" is reached, 
the default message 
"struts.messages.upload.error.FileUploadException=Error uploading: {0}!" 
(struts-messages.properties) always displays the "{0}" instead of 
replacing it with the actual filename.  In looking at the code, it might 
be difficult to bubble up the filename from the source of the exception, 
but that would be the preferred solution.  Otherwise, it might make 
sense to change the default upload error message without the {0} 
parameters (e.g. "Error uploading the file", or "Error parsing the 
request."). Thoughts?


[AbstractMultiPartRequest.java]

     public void parse(HttpServletRequest request, String saveDir) throws 
IOException {
         try {
             processUpload(request, saveDir);
         } catch (FileUploadException e) {
             LOG.debug("Request exceeded size limit!", e);
             LocalizedMessage errorMessage;
             if (e instanceof FileUploadByteCountLimitException ex) {
                 errorMessage = buildErrorMessage(e, new Object[]{
                         ex.getFieldName(), ex.getFileName(), 
ex.getPermitted(), ex.getActualSize()
                 });
             } else if (e instanceof FileUploadFileCountLimitException 
ex) {
                 errorMessage = buildErrorMessage(e, new Object[]{
                         ex.getPermitted(), ex.getActualSize()
                 });
             } else if (e instanceof FileUploadSizeException ex) {
                 errorMessage = buildErrorMessage(e, new Object[]{
                         ex.getPermitted(), ex.getActualSize()
                 });
             } else if (e instanceof FileUploadContentTypeException ex) {
                 errorMessage = buildErrorMessage(e, new Object[]{
                         ex.getContentType()
                 });

// FINAL ELSE
             } else {
                 errorMessage = buildErrorMessage(e, new Object[]{});
             }

             if (!errors.contains(errorMessage)) {
                 errors.add(errorMessage);
             }
         } catch (IOException e) {
             LOG.debug("Unable to parse request", e);
             LocalizedMessage errorMessage = buildErrorMessage(e, new 
Object[]{});
             if (!errors.contains(errorMessage)) {
                 errors.add(errorMessage);
             }
         }
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [7.0.0-M3] Error message

Posted by Lukasz Lenart <lu...@apache.org>.
pt., 16 lut 2024 o 10:45 Greg Huber <gr...@gmail.com> napisał(a):
>
> What happened to M3? There is no tag on https://github.com/apache/struts

My bad, there was no M3 jest M2 :D So expect M3 soon ;-)

Cheers
Lukasz

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [7.0.0-M3] Error message

Posted by Greg Huber <gr...@gmail.com>.
What happened to M3? There is no tag on https://github.com/apache/struts

On 16/02/2024 07:27, Lukasz Lenart wrote:
> I'm going to prepare another M4 which will contain the latest fixes
> around file upload and changes from the master branch
>
> pt., 9 lut 2024 o 16:53 Burton Rhodes<bu...@gmail.com>  napisał(a):
>> Lastly, I am also finding a ton of these log entries below.  I'm not
>> sure why they are happening either, but to be honest, I haven't had much
>> time to investigate.  "upload" is the form field name, BTW.  I will try
>> to do some more investigating on these over the weekend.
>>
>> Feb 08 09:29:12 lb-group-web-app-v1d2-dqsv afs-site: WARN
>> o.a.s.i.ActionFileUploadInterceptor: Could not find a Filename for
>> upload. Verify that a valid file was submitted.
>>    Feb 08 09:29:12 lb-group-web-app-v1d2-dqsv afs-site: WARN
>> o.a.s.i.FileUploadInterceptor: Could not find a Content-Type for upload.
>> Verify that a valid file was submitted.
>>
>>    Feb 08 09:33:39 lb-group-web-app-v1d2-dqsv afs-site: WARN
>> o.a.s.i.ActionFileUploadInterceptor: Could not find a Filename for
>> upload. Verify that a valid file was submitted.
>>    Feb 08 09:33:39 lb-group-web-app-v1d2-dqsv afs-site: WARN
>> o.a.s.i.FileUploadInterceptor: Could not find a Content-Type for upload.
>> Verify that a valid file was submitted.
>>
>>
>> ------ Original Message ------
>>  From "Burton Rhodes"<bu...@gmail.com>
>> To "Struts Developers List"<de...@struts.apache.org>
>> Date 2/9/2024 9:43:18 AM
>> Subject Re: [7.0.0-M3] Error message
>>
>>> Also, I am finding quite a few of these "generic" errors in my logs (Error uploading: {0}!), and I believe it's happening when the upload fails either through a broken pipe/connection or client abort.  I haven't had the time to test it though to be sure why these are being generated in my error logs.
>>>
>>>
>>>
>>> ------ Original Message ------
>> >From "Burton Rhodes" <bu...@gmail.com>
>>> To "Struts Developers List"<de...@struts.apache.org>
>>> Date 2/9/2024 9:38:12 AM
>>> Subject Re: [7.0.0-M3] Error message
>>>
>>>> The easiest example is when a custom "saveDir" is not accessible.  (e.g. no security access).  This will throw a generic FileUploadException with no identifiable file.
>>>>
>>>>
>>>> ------ Original Message ------
>>> >From "Lukasz Lenart" <lu...@apache.org>
>>>> To "Struts Developers List"<de...@struts.apache.org>
>>>> Date 2/9/2024 9:34:36 AM
>>>> Subject Re: [7.0.0-M3] Error message
>>>>
>>>>> pt., 9 lut 2024 o 16:21 Burton Rhodes<bu...@gmail.com>  napisał(a):
>>>>>>   I haven't had time yet, but I will try this weekend.
>>>>> Could you share a use case when it can happen?
>>>>>
>>>>>
>>>>> Cheers
>>>>> Lukasz
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail:dev-unsubscribe@struts.apache.org
>>>>> For additional commands, e-mail:dev-help@struts.apache.org
>>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:dev-unsubscribe@struts.apache.org
>> For additional commands, e-mail:dev-help@struts.apache.org
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:dev-unsubscribe@struts.apache.org
> For additional commands, e-mail:dev-help@struts.apache.org
>

Re: [7.0.0-M3] Error message

Posted by Lukasz Lenart <lu...@apache.org>.
I'm going to prepare another M4 which will contain the latest fixes
around file upload and changes from the master branch

pt., 9 lut 2024 o 16:53 Burton Rhodes <bu...@gmail.com> napisał(a):
>
> Lastly, I am also finding a ton of these log entries below.  I'm not
> sure why they are happening either, but to be honest, I haven't had much
> time to investigate.  "upload" is the form field name, BTW.  I will try
> to do some more investigating on these over the weekend.
>
> Feb 08 09:29:12 lb-group-web-app-v1d2-dqsv afs-site: WARN
> o.a.s.i.ActionFileUploadInterceptor: Could not find a Filename for
> upload. Verify that a valid file was submitted.
>   Feb 08 09:29:12 lb-group-web-app-v1d2-dqsv afs-site: WARN
> o.a.s.i.FileUploadInterceptor: Could not find a Content-Type for upload.
> Verify that a valid file was submitted.
>
>   Feb 08 09:33:39 lb-group-web-app-v1d2-dqsv afs-site: WARN
> o.a.s.i.ActionFileUploadInterceptor: Could not find a Filename for
> upload. Verify that a valid file was submitted.
>   Feb 08 09:33:39 lb-group-web-app-v1d2-dqsv afs-site: WARN
> o.a.s.i.FileUploadInterceptor: Could not find a Content-Type for upload.
> Verify that a valid file was submitted.
>
>
> ------ Original Message ------
> From "Burton Rhodes" <bu...@gmail.com>
> To "Struts Developers List" <de...@struts.apache.org>
> Date 2/9/2024 9:43:18 AM
> Subject Re: [7.0.0-M3] Error message
>
> >Also, I am finding quite a few of these "generic" errors in my logs (Error uploading: {0}!), and I believe it's happening when the upload fails either through a broken pipe/connection or client abort.  I haven't had the time to test it though to be sure why these are being generated in my error logs.
> >
> >
> >
> >------ Original Message ------
> >From "Burton Rhodes" <bu...@gmail.com>
> >To "Struts Developers List" <de...@struts.apache.org>
> >Date 2/9/2024 9:38:12 AM
> >Subject Re: [7.0.0-M3] Error message
> >
> >>The easiest example is when a custom "saveDir" is not accessible.  (e.g. no security access).  This will throw a generic FileUploadException with no identifiable file.
> >>
> >>
> >>------ Original Message ------
> >>From "Lukasz Lenart" <lu...@apache.org>
> >>To "Struts Developers List" <de...@struts.apache.org>
> >>Date 2/9/2024 9:34:36 AM
> >>Subject Re: [7.0.0-M3] Error message
> >>
> >>>pt., 9 lut 2024 o 16:21 Burton Rhodes <bu...@gmail.com> napisał(a):
> >>>>
> >>>>  I haven't had time yet, but I will try this weekend.
> >>>
> >>>Could you share a use case when it can happen?
> >>>
> >>>
> >>>Cheers
> >>>Lukasz
> >>>
> >>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> >>>For additional commands, e-mail: dev-help@struts.apache.org
> >>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [7.0.0-M3] Error message

Posted by Burton Rhodes <bu...@gmail.com>.
Lastly, I am also finding a ton of these log entries below.  I'm not 
sure why they are happening either, but to be honest, I haven't had much 
time to investigate.  "upload" is the form field name, BTW.  I will try 
to do some more investigating on these over the weekend.

Feb 08 09:29:12 lb-group-web-app-v1d2-dqsv afs-site: WARN 
o.a.s.i.ActionFileUploadInterceptor: Could not find a Filename for 
upload. Verify that a valid file was submitted.
  Feb 08 09:29:12 lb-group-web-app-v1d2-dqsv afs-site: WARN 
o.a.s.i.FileUploadInterceptor: Could not find a Content-Type for upload. 
Verify that a valid file was submitted.

  Feb 08 09:33:39 lb-group-web-app-v1d2-dqsv afs-site: WARN 
o.a.s.i.ActionFileUploadInterceptor: Could not find a Filename for 
upload. Verify that a valid file was submitted.
  Feb 08 09:33:39 lb-group-web-app-v1d2-dqsv afs-site: WARN 
o.a.s.i.FileUploadInterceptor: Could not find a Content-Type for upload. 
Verify that a valid file was submitted.


------ Original Message ------
From "Burton Rhodes" <bu...@gmail.com>
To "Struts Developers List" <de...@struts.apache.org>
Date 2/9/2024 9:43:18 AM
Subject Re: [7.0.0-M3] Error message

>Also, I am finding quite a few of these "generic" errors in my logs (Error uploading: {0}!), and I believe it's happening when the upload fails either through a broken pipe/connection or client abort.  I haven't had the time to test it though to be sure why these are being generated in my error logs.
>
>
>
>------ Original Message ------
>From "Burton Rhodes" <bu...@gmail.com>
>To "Struts Developers List" <de...@struts.apache.org>
>Date 2/9/2024 9:38:12 AM
>Subject Re: [7.0.0-M3] Error message
>
>>The easiest example is when a custom "saveDir" is not accessible.  (e.g. no security access).  This will throw a generic FileUploadException with no identifiable file.
>>
>>
>>------ Original Message ------
>>From "Lukasz Lenart" <lu...@apache.org>
>>To "Struts Developers List" <de...@struts.apache.org>
>>Date 2/9/2024 9:34:36 AM
>>Subject Re: [7.0.0-M3] Error message
>>
>>>pt., 9 lut 2024 o 16:21 Burton Rhodes <bu...@gmail.com> napisał(a):
>>>>
>>>>  I haven't had time yet, but I will try this weekend.
>>>
>>>Could you share a use case when it can happen?
>>>
>>>
>>>Cheers
>>>Lukasz
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>>>For additional commands, e-mail: dev-help@struts.apache.org
>>>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [7.0.0-M3] Error message

Posted by Burton Rhodes <bu...@gmail.com>.
Also, I am finding quite a few of these "generic" errors in my logs 
(Error uploading: {0}!), and I believe it's happening when the upload 
fails either through a broken pipe/connection or client abort.  I 
haven't had the time to test it though to be sure why these are being 
generated in my error logs.



------ Original Message ------
From "Burton Rhodes" <bu...@gmail.com>
To "Struts Developers List" <de...@struts.apache.org>
Date 2/9/2024 9:38:12 AM
Subject Re: [7.0.0-M3] Error message

>The easiest example is when a custom "saveDir" is not accessible.  (e.g. no security access).  This will throw a generic FileUploadException with no identifiable file.
>
>
>------ Original Message ------
>From "Lukasz Lenart" <lu...@apache.org>
>To "Struts Developers List" <de...@struts.apache.org>
>Date 2/9/2024 9:34:36 AM
>Subject Re: [7.0.0-M3] Error message
>
>>pt., 9 lut 2024 o 16:21 Burton Rhodes <bu...@gmail.com> napisał(a):
>>>
>>>  I haven't had time yet, but I will try this weekend.
>>
>>Could you share a use case when it can happen?
>>
>>
>>Cheers
>>Lukasz
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>>For additional commands, e-mail: dev-help@struts.apache.org
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [7.0.0-M3] Error message

Posted by Burton Rhodes <bu...@gmail.com>.
The easiest example is when a custom "saveDir" is not accessible.  (e.g. 
no security access).  This will throw a generic FileUploadException with 
no identifiable file.


------ Original Message ------
From "Lukasz Lenart" <lu...@apache.org>
To "Struts Developers List" <de...@struts.apache.org>
Date 2/9/2024 9:34:36 AM
Subject Re: [7.0.0-M3] Error message

>pt., 9 lut 2024 o 16:21 Burton Rhodes <bu...@gmail.com> napisał(a):
>>
>>  I haven't had time yet, but I will try this weekend.
>
>Could you share a use case when it can happen?
>
>
>Cheers
>Lukasz
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>For additional commands, e-mail: dev-help@struts.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [7.0.0-M3] Error message

Posted by Lukasz Lenart <lu...@apache.org>.
pt., 9 lut 2024 o 16:21 Burton Rhodes <bu...@gmail.com> napisał(a):
>
> I haven't had time yet, but I will try this weekend.

Could you share a use case when it can happen?


Cheers
Lukasz

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [7.0.0-M3] Error message

Posted by Burton Rhodes <bu...@gmail.com>.
I haven't had time yet, but I will try this weekend.


------ Original Message ------
From "Lukasz Lenart" <lu...@apache.org>
To "Struts Developers List" <de...@struts.apache.org>
Date 2/9/2024 9:18:45 AM
Subject Re: [7.0.0-M3] Error message

>Have you found a solution to this problem? I can take a look during the weekend
>
>pon., 5 lut 2024 o 16:51 Burton Rhodes <bu...@gmail.com> napisał(a):
>>
>>  When catching a FileUploadException in the
>>  AbstractMultiPartRequest.parse() method, if the final "else" is reached,
>>  the default message
>>  "struts.messages.upload.error.FileUploadException=Error uploading: {0}!"
>>  (struts-messages.properties) always displays the "{0}" instead of
>>  replacing it with the actual filename.  In looking at the code, it might
>>  be difficult to bubble up the filename from the source of the exception,
>>  but that would be the preferred solution.  Otherwise, it might make
>>  sense to change the default upload error message without the {0}
>>  parameters (e.g. "Error uploading the file", or "Error parsing the
>>  request."). Thoughts?
>>
>>
>>  [AbstractMultiPartRequest.java]
>>
>>       public void parse(HttpServletRequest request, String saveDir) throws
>>  IOException {
>>           try {
>>               processUpload(request, saveDir);
>>           } catch (FileUploadException e) {
>>               LOG.debug("Request exceeded size limit!", e);
>>               LocalizedMessage errorMessage;
>>               if (e instanceof FileUploadByteCountLimitException ex) {
>>                   errorMessage = buildErrorMessage(e, new Object[]{
>>                           ex.getFieldName(), ex.getFileName(),
>>  ex.getPermitted(), ex.getActualSize()
>>                   });
>>               } else if (e instanceof FileUploadFileCountLimitException
>>  ex) {
>>                   errorMessage = buildErrorMessage(e, new Object[]{
>>                           ex.getPermitted(), ex.getActualSize()
>>                   });
>>               } else if (e instanceof FileUploadSizeException ex) {
>>                   errorMessage = buildErrorMessage(e, new Object[]{
>>                           ex.getPermitted(), ex.getActualSize()
>>                   });
>>               } else if (e instanceof FileUploadContentTypeException ex) {
>>                   errorMessage = buildErrorMessage(e, new Object[]{
>>                           ex.getContentType()
>>                   });
>>
>>  // FINAL ELSE
>>               } else {
>>                   errorMessage = buildErrorMessage(e, new Object[]{});
>>               }
>>
>>               if (!errors.contains(errorMessage)) {
>>                   errors.add(errorMessage);
>>               }
>>           } catch (IOException e) {
>>               LOG.debug("Unable to parse request", e);
>>               LocalizedMessage errorMessage = buildErrorMessage(e, new
>>  Object[]{});
>>               if (!errors.contains(errorMessage)) {
>>                   errors.add(errorMessage);
>>               }
>>           }
>>       }
>>
>>
>>  ---------------------------------------------------------------------
>>  To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>>  For additional commands, e-mail: dev-help@struts.apache.org
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>For additional commands, e-mail: dev-help@struts.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [7.0.0-M3] Error message

Posted by Lukasz Lenart <lu...@apache.org>.
Have you found a solution to this problem? I can take a look during the weekend

pon., 5 lut 2024 o 16:51 Burton Rhodes <bu...@gmail.com> napisał(a):
>
> When catching a FileUploadException in the
> AbstractMultiPartRequest.parse() method, if the final "else" is reached,
> the default message
> "struts.messages.upload.error.FileUploadException=Error uploading: {0}!"
> (struts-messages.properties) always displays the "{0}" instead of
> replacing it with the actual filename.  In looking at the code, it might
> be difficult to bubble up the filename from the source of the exception,
> but that would be the preferred solution.  Otherwise, it might make
> sense to change the default upload error message without the {0}
> parameters (e.g. "Error uploading the file", or "Error parsing the
> request."). Thoughts?
>
>
> [AbstractMultiPartRequest.java]
>
>      public void parse(HttpServletRequest request, String saveDir) throws
> IOException {
>          try {
>              processUpload(request, saveDir);
>          } catch (FileUploadException e) {
>              LOG.debug("Request exceeded size limit!", e);
>              LocalizedMessage errorMessage;
>              if (e instanceof FileUploadByteCountLimitException ex) {
>                  errorMessage = buildErrorMessage(e, new Object[]{
>                          ex.getFieldName(), ex.getFileName(),
> ex.getPermitted(), ex.getActualSize()
>                  });
>              } else if (e instanceof FileUploadFileCountLimitException
> ex) {
>                  errorMessage = buildErrorMessage(e, new Object[]{
>                          ex.getPermitted(), ex.getActualSize()
>                  });
>              } else if (e instanceof FileUploadSizeException ex) {
>                  errorMessage = buildErrorMessage(e, new Object[]{
>                          ex.getPermitted(), ex.getActualSize()
>                  });
>              } else if (e instanceof FileUploadContentTypeException ex) {
>                  errorMessage = buildErrorMessage(e, new Object[]{
>                          ex.getContentType()
>                  });
>
> // FINAL ELSE
>              } else {
>                  errorMessage = buildErrorMessage(e, new Object[]{});
>              }
>
>              if (!errors.contains(errorMessage)) {
>                  errors.add(errorMessage);
>              }
>          } catch (IOException e) {
>              LOG.debug("Unable to parse request", e);
>              LocalizedMessage errorMessage = buildErrorMessage(e, new
> Object[]{});
>              if (!errors.contains(errorMessage)) {
>                  errors.add(errorMessage);
>              }
>          }
>      }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [7.0.0-M3] Build/Run Test :: freemarker.core package does not exist

Posted by Lukasz Lenart <lu...@apache.org>.
pon., 5 lut 2024 o 17:13 Burton Rhodes <bu...@gmail.com> napisał(a):
>
> I can build and install the struts code base [struts2-parent] when
> skipping tests; however, I am unable to run any test due to a test build
> error.  I get "package freemarker.core does not exist" in several
> classes containing "import freemarker.core.*" within the [struts2-core]
> package.  Any tips on how I can solve this?

I'm using the following trick to run tests inside IDE. Just run "mvn
install" first and then apply this patch
https://github.com/apache/struts/pull/871


Cheers
Łukasz

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


[7.0.0-M3] Build/Run Test :: freemarker.core package does not exist

Posted by Burton Rhodes <bu...@gmail.com>.
I can build and install the struts code base [struts2-parent] when 
skipping tests; however, I am unable to run any test due to a test build 
error.  I get "package freemarker.core does not exist" in several 
classes containing "import freemarker.core.*" within the [struts2-core] 
package.  Any tips on how I can solve this?

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org