You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nifi.apache.org by Nissim Shiman <ns...@yahoo.com.INVALID> on 2020/11/19 18:06:11 UTC

FILE_EXISTS_VALIDATOR allows directories as well, is this a feature or a bug?

Hello Nifi devs,
It has been noticed that the StandardValidators.FILE_EXISTS_VALIDATOR [1] verifies that a value exists, but it does not verify that it is a file, as opposed to being a directory [2]

Is this by design or is it worthy of a bug fix?


[1]  https://github.com/apache/nifi/blob/main/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/processor/util/StandardValidators.java#L505[2] https://github.com/apache/nifi/blob/main/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/processor/util/StandardValidators.java#L851-L852

Thanks,
Nissim Shiman

Re: FILE_EXISTS_VALIDATOR allows directories as well, is this a feature or a bug?

Posted by Nissim Shiman <ns...@yahoo.com.INVALID>.
 Thank you Mike and Lars for your feedback!


I like your idea of "a second constructor that allows you to set a boolean flag to put in a "file-only" mode."I think that is the most graceful way forward.

I think we are OK with not having another validator for validating folders as being folders as it seems that it can be done using the code that already exists [1][2]



[1] https://github.com/apache/nifi/blob/main/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/GetFile.java#L115[2] https://github.com/apache/nifi/blob/main/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/main/java/org/apache/nifi/controller/MonitorDiskUsage.java#L55
Thank You!

Nissim
    On Saturday, November 28, 2020, 03:56:38 PM EST, Mike Thomsen <mi...@gmail.com> wrote:  
 
 Lars,

I think we'd be better off keeping it simple like
FILE_EXISTENCE_VALIDATOR and FOLDER_EXISTENCE_VALIDATOR. I'm not sure
that symlinks are really an issue here for validation purposes.
Regardless, we'd need to give community members with their own custom
bundles a good 2-3 releases worth of @Deprecated warning on the
current validator before removing it would be something we could
consider.

Thanks,

Mike

On Sat, Nov 28, 2020 at 1:36 PM Lars Winderling
<la...@posteo.de> wrote:
>
> Mike,
>
> what about giving it another name then like REAL_FILE_VALIDATOR? It's not perfect, but it draws from the distinction between real (proper) files on the one, and symlinks, dirs etc in the other side, like many apis use it. I'm not quite sure, what do you think?
> Best,
> Lars
>
> On 28 November 2020 16:37:41 CET, Mike Thomsen <mi...@gmail.com> wrote:
> >Nissim,
> >
> >If I had to guess, it was an oversight that it handles both folders
> >and files. Any refactored version would have to not change the current
> >default behavior. So, what I'd suggest would be a second constructor
> >that allows you to set a boolean flag to put in a "file-only" mode and
> >then add another validator that checks for the existence of a folder
> >and that it is a folder, not a file.
> >
> >Thanks,
> >
> >Mike
> >
> >On Thu, Nov 19, 2020 at 1:06 PM Nissim Shiman
> ><ns...@yahoo.com.invalid> wrote:
> >>
> >> Hello Nifi devs,
> >> It has been noticed that the StandardValidators.FILE_EXISTS_VALIDATOR
> >[1] verifies that a value exists, but it does not verify that it is a
> >file, as opposed to being a directory [2]
> >>
> >> Is this by design or is it worthy of a bug fix?
> >>
> >>
> >> [1]
> >https://github.com/apache/nifi/blob/main/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/processor/util/StandardValidators.java#L505[2]
> >https://github.com/apache/nifi/blob/main/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/processor/util/StandardValidators.java#L851-L852
> >>
> >> Thanks,
> >> Nissim Shiman  

Re: FILE_EXISTS_VALIDATOR allows directories as well, is this a feature or a bug?

Posted by Mike Thomsen <mi...@gmail.com>.
Lars,

I think we'd be better off keeping it simple like
FILE_EXISTENCE_VALIDATOR and FOLDER_EXISTENCE_VALIDATOR. I'm not sure
that symlinks are really an issue here for validation purposes.
Regardless, we'd need to give community members with their own custom
bundles a good 2-3 releases worth of @Deprecated warning on the
current validator before removing it would be something we could
consider.

Thanks,

Mike

On Sat, Nov 28, 2020 at 1:36 PM Lars Winderling
<la...@posteo.de> wrote:
>
> Mike,
>
> what about giving it another name then like REAL_FILE_VALIDATOR? It's not perfect, but it draws from the distinction between real (proper) files on the one, and symlinks, dirs etc in the other side, like many apis use it. I'm not quite sure, what do you think?
> Best,
> Lars
>
> On 28 November 2020 16:37:41 CET, Mike Thomsen <mi...@gmail.com> wrote:
> >Nissim,
> >
> >If I had to guess, it was an oversight that it handles both folders
> >and files. Any refactored version would have to not change the current
> >default behavior. So, what I'd suggest would be a second constructor
> >that allows you to set a boolean flag to put in a "file-only" mode and
> >then add another validator that checks for the existence of a folder
> >and that it is a folder, not a file.
> >
> >Thanks,
> >
> >Mike
> >
> >On Thu, Nov 19, 2020 at 1:06 PM Nissim Shiman
> ><ns...@yahoo.com.invalid> wrote:
> >>
> >> Hello Nifi devs,
> >> It has been noticed that the StandardValidators.FILE_EXISTS_VALIDATOR
> >[1] verifies that a value exists, but it does not verify that it is a
> >file, as opposed to being a directory [2]
> >>
> >> Is this by design or is it worthy of a bug fix?
> >>
> >>
> >> [1]
> >https://github.com/apache/nifi/blob/main/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/processor/util/StandardValidators.java#L505[2]
> >https://github.com/apache/nifi/blob/main/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/processor/util/StandardValidators.java#L851-L852
> >>
> >> Thanks,
> >> Nissim Shiman

Re: FILE_EXISTS_VALIDATOR allows directories as well, is this a feature or a bug?

Posted by Lars Winderling <la...@posteo.de>.
Mike,

what about giving it another name then like REAL_FILE_VALIDATOR? It's not perfect, but it draws from the distinction between real (proper) files on the one, and symlinks, dirs etc in the other side, like many apis use it. I'm not quite sure, what do you think?
Best,
Lars

On 28 November 2020 16:37:41 CET, Mike Thomsen <mi...@gmail.com> wrote:
>Nissim,
>
>If I had to guess, it was an oversight that it handles both folders
>and files. Any refactored version would have to not change the current
>default behavior. So, what I'd suggest would be a second constructor
>that allows you to set a boolean flag to put in a "file-only" mode and
>then add another validator that checks for the existence of a folder
>and that it is a folder, not a file.
>
>Thanks,
>
>Mike
>
>On Thu, Nov 19, 2020 at 1:06 PM Nissim Shiman
><ns...@yahoo.com.invalid> wrote:
>>
>> Hello Nifi devs,
>> It has been noticed that the StandardValidators.FILE_EXISTS_VALIDATOR
>[1] verifies that a value exists, but it does not verify that it is a
>file, as opposed to being a directory [2]
>>
>> Is this by design or is it worthy of a bug fix?
>>
>>
>> [1] 
>https://github.com/apache/nifi/blob/main/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/processor/util/StandardValidators.java#L505[2]
>https://github.com/apache/nifi/blob/main/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/processor/util/StandardValidators.java#L851-L852
>>
>> Thanks,
>> Nissim Shiman

Re: FILE_EXISTS_VALIDATOR allows directories as well, is this a feature or a bug?

Posted by Mike Thomsen <mi...@gmail.com>.
Nissim,

If I had to guess, it was an oversight that it handles both folders
and files. Any refactored version would have to not change the current
default behavior. So, what I'd suggest would be a second constructor
that allows you to set a boolean flag to put in a "file-only" mode and
then add another validator that checks for the existence of a folder
and that it is a folder, not a file.

Thanks,

Mike

On Thu, Nov 19, 2020 at 1:06 PM Nissim Shiman <ns...@yahoo.com.invalid> wrote:
>
> Hello Nifi devs,
> It has been noticed that the StandardValidators.FILE_EXISTS_VALIDATOR [1] verifies that a value exists, but it does not verify that it is a file, as opposed to being a directory [2]
>
> Is this by design or is it worthy of a bug fix?
>
>
> [1]  https://github.com/apache/nifi/blob/main/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/processor/util/StandardValidators.java#L505[2] https://github.com/apache/nifi/blob/main/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/processor/util/StandardValidators.java#L851-L852
>
> Thanks,
> Nissim Shiman