You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "dan-s1 (via GitHub)" <gi...@apache.org> on 2025/11/26 22:16:56 UTC

[PR] NIFI-15261 Added URL/URI validation for properties representing a URL/URI [nifi]

dan-s1 opened a new pull request, #10569:
URL: https://github.com/apache/nifi/pull/10569

   <!-- Licensed to the Apache Software Foundation (ASF) under one or more -->
   <!-- contributor license agreements.  See the NOTICE file distributed with -->
   <!-- this work for additional information regarding copyright ownership. -->
   <!-- The ASF licenses this file to You under the Apache License, Version 2.0 -->
   <!-- (the "License"); you may not use this file except in compliance with -->
   <!-- the License.  You may obtain a copy of the License at -->
   <!--     http://www.apache.org/licenses/LICENSE-2.0 -->
   <!-- Unless required by applicable law or agreed to in writing, software -->
   <!-- distributed under the License is distributed on an "AS IS" BASIS, -->
   <!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -->
   <!-- See the License for the specific language governing permissions and -->
   <!-- limitations under the License. -->
   
   # Summary
   
   [NIFI-15261](https://issues.apache.org/jira/browse/NIFI-15261)
   
   # Tracking
   
   Please complete the following tracking steps prior to pull request creation.
   
   ### Issue Tracking
   
   - [ ] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created
   
   ### Pull Request Tracking
   
   - [ ] Pull Request title starts with Apache NiFi Jira issue number, such as `NIFI-00000`
   - [ ] Pull Request commit message starts with Apache NiFi Jira issue number, as such `NIFI-00000`
   
   ### Pull Request Formatting
   
   - [ ] Pull Request based on current revision of the `main` branch
   - [ ] Pull Request refers to a feature branch with one commit containing changes
   
   # Verification
   
   Please indicate the verification steps performed prior to pull request creation.
   
   ### Build
   
   - [ ] Build completed using `./mvnw clean install -P contrib-check`
     - [ ] JDK 21
     - [ ] JDK 25
   
   ### Licensing
   
   - [ ] New dependencies are compatible with the [Apache License 2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License Policy](https://www.apache.org/legal/resolved.html)
   - [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` files
   
   ### Documentation
   
   - [ ] Documentation formatting appears as expected in rendered files
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-15261 Added URL/URI validation for properties representing a URL/URI [nifi]

Posted by "dan-s1 (via GitHub)" <gi...@apache.org>.
dan-s1 commented on code in PR #10569:
URL: https://github.com/apache/nifi/pull/10569#discussion_r2567123794


##########
nifi-extension-bundles/nifi-atlassian-bundle/nifi-atlassian-extensions/src/main/java/org/apache/nifi/atlassian/bitbucket/BitbucketFlowRegistryClient.java:
##########
@@ -49,7 +49,7 @@ public class BitbucketFlowRegistryClient extends AbstractGitFlowRegistryClient {
     static final PropertyDescriptor BITBUCKET_API_URL = new PropertyDescriptor.Builder()
             .name("Bitbucket API Instance")
             .description("The Bitbucket API host or base URL (for example, api.bitbucket.org for Cloud or https://bitbucket.example.com for Data Center)")
-            .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
+            .addValidator(StandardValidators.URL_VALIDATOR)

Review Comment:
   In the URL_VALIDATOR there is a regex for a host named `HOST_PATTERN`. Couldn't we have here a custom validator to match either against  a host using that regex (probably cutting and pasting that regex) or matching a URL using the URL_VALIDATOR? Something like the following:
   
   ```
    private static final Pattern HOST_PATTERN = Pattern.compile("(\\[[\\p{XDigit}:.]*[%\\p{Alnum}]*]|[^\\[/?#:]*)");
       private static final Validator BITBUCKET_API_URL_VALIDATOR = (subject, input, validationContext) -> {
           if (HOST_PATTERN.matcher(input).matches()) {
               return (new ValidationResult.Builder()).subject(subject).input(input).valid(true).build();
           } else {
               ValidationResult validationResult = StandardValidators.URL_VALIDATOR.validate(subject, input, validationContext);
               if (validationResult.isValid()) {
                   return validationResult;
               } else {
                   return (new ValidationResult.Builder()).subject(subject).explanation(String.format("'%s' is neither a host or URL", subject)).input(input).build();
               }
           }
       };
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-15261 Added URL/URI validation for properties representing a URL/URI [nifi]

Posted by "dan-s1 (via GitHub)" <gi...@apache.org>.
dan-s1 commented on code in PR #10569:
URL: https://github.com/apache/nifi/pull/10569#discussion_r2567123794


##########
nifi-extension-bundles/nifi-atlassian-bundle/nifi-atlassian-extensions/src/main/java/org/apache/nifi/atlassian/bitbucket/BitbucketFlowRegistryClient.java:
##########
@@ -49,7 +49,7 @@ public class BitbucketFlowRegistryClient extends AbstractGitFlowRegistryClient {
     static final PropertyDescriptor BITBUCKET_API_URL = new PropertyDescriptor.Builder()
             .name("Bitbucket API Instance")
             .description("The Bitbucket API host or base URL (for example, api.bitbucket.org for Cloud or https://bitbucket.example.com for Data Center)")
-            .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
+            .addValidator(StandardValidators.URL_VALIDATOR)

Review Comment:
   In the URL_VALIDATOR there is a regex for a host named `HOST_PATTERN`. Couldn't we have here a custom validator to match either against  a host using this regex or matching a URL using the URL_VALIDATOR.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-15261 Added URL/URI validation for properties representing a URL/URI [nifi]

Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory commented on code in PR #10569:
URL: https://github.com/apache/nifi/pull/10569#discussion_r2567149752


##########
nifi-extension-bundles/nifi-atlassian-bundle/nifi-atlassian-extensions/src/main/java/org/apache/nifi/atlassian/bitbucket/BitbucketFlowRegistryClient.java:
##########
@@ -49,7 +49,7 @@ public class BitbucketFlowRegistryClient extends AbstractGitFlowRegistryClient {
     static final PropertyDescriptor BITBUCKET_API_URL = new PropertyDescriptor.Builder()
             .name("Bitbucket API Instance")
             .description("The Bitbucket API host or base URL (for example, api.bitbucket.org for Cloud or https://bitbucket.example.com for Data Center)")
-            .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
+            .addValidator(StandardValidators.URL_VALIDATOR)

Review Comment:
   That might work, I would consider that in a separate pull request.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-15261 Added URL/URI validation for properties representing a URL/URI [nifi]

Posted by "dan-s1 (via GitHub)" <gi...@apache.org>.
dan-s1 commented on PR #10569:
URL: https://github.com/apache/nifi/pull/10569#issuecomment-3584089037

   > Thanks @dan-s1, some of these changes appear to introduce more strict validation than necessary, potentially creating issues. I noted the changes that seemed problematic. Have you evaluated whether these changes support existing configurations, based on unit tests or runtime tests?
   
   I have not evaluated or tested anything else but the current unit tests.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-15261 Added URL/URI validation for properties representing a URL/URI [nifi]

Posted by "dan-s1 (via GitHub)" <gi...@apache.org>.
dan-s1 commented on code in PR #10569:
URL: https://github.com/apache/nifi/pull/10569#discussion_r2567123794


##########
nifi-extension-bundles/nifi-atlassian-bundle/nifi-atlassian-extensions/src/main/java/org/apache/nifi/atlassian/bitbucket/BitbucketFlowRegistryClient.java:
##########
@@ -49,7 +49,7 @@ public class BitbucketFlowRegistryClient extends AbstractGitFlowRegistryClient {
     static final PropertyDescriptor BITBUCKET_API_URL = new PropertyDescriptor.Builder()
             .name("Bitbucket API Instance")
             .description("The Bitbucket API host or base URL (for example, api.bitbucket.org for Cloud or https://bitbucket.example.com for Data Center)")
-            .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
+            .addValidator(StandardValidators.URL_VALIDATOR)

Review Comment:
   In the URL_VALIDATOR there is a regex for a host named `HOST_PATTERN`. Couldn't we have here a custom validator to match either against  a host using that regex (probably cutting and pasting that regex) or matching a URL using the URL_VALIDATOR? Something like the following:
   
   ```
    private static final Pattern HOST_PATTERN = Pattern.compile("(\\[[\\p{XDigit}:.]*[%\\p{Alnum}]*]|[^\\[/?#:]*)");
    private static final Validator BITBUCKET_API_URL_VALIDATOR = (subject, input, validationContext) -> {
           if (HOST_PATTERN.matcher(input).matches()) {
               return (new ValidationResult.Builder()).subject(subject).input(input).valid(true).build();
           } else {
               ValidationResult validationResult = StandardValidators.URL_VALIDATOR.validate(subject, input, validationContext);
               if (validationResult.isValid()) {
                   return validationResult;
               } else {
                   return (new ValidationResult.Builder()).subject(subject).explanation(String.format("'%s' is neither a host or URL", subject)).input(input).build();
               }
           }
       };
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-15261 Added URL/URI validation for properties representing a URL/URI [nifi]

Posted by "dan-s1 (via GitHub)" <gi...@apache.org>.
dan-s1 commented on code in PR #10569:
URL: https://github.com/apache/nifi/pull/10569#discussion_r2567123794


##########
nifi-extension-bundles/nifi-atlassian-bundle/nifi-atlassian-extensions/src/main/java/org/apache/nifi/atlassian/bitbucket/BitbucketFlowRegistryClient.java:
##########
@@ -49,7 +49,7 @@ public class BitbucketFlowRegistryClient extends AbstractGitFlowRegistryClient {
     static final PropertyDescriptor BITBUCKET_API_URL = new PropertyDescriptor.Builder()
             .name("Bitbucket API Instance")
             .description("The Bitbucket API host or base URL (for example, api.bitbucket.org for Cloud or https://bitbucket.example.com for Data Center)")
-            .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
+            .addValidator(StandardValidators.URL_VALIDATOR)

Review Comment:
   In the URL_VALIDATOR there is a regex for a host named `HOST_PATTERN`. Couldn't we have here a custom validator to match either against  a host using that regex (probably cutting and pasting that regex) or matching a URL using the URL_VALIDATOR?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-15261 Added URL/URI validation for properties representing a URL/URI [nifi]

Posted by "dan-s1 (via GitHub)" <gi...@apache.org>.
dan-s1 commented on code in PR #10569:
URL: https://github.com/apache/nifi/pull/10569#discussion_r2567097291


##########
nifi-extension-bundles/nifi-snowflake-bundle/nifi-snowflake-services/src/main/java/org/apache/nifi/snowflake/service/StandardSnowflakeIngestManagerProviderService.java:
##########
@@ -58,7 +58,7 @@ public class StandardSnowflakeIngestManagerProviderService extends AbstractContr
     public static final PropertyDescriptor HOST_URL = new PropertyDescriptor.Builder()
             .name("Snowflake URL")
             .description("Example host url: [account-locator].[cloud-region].[cloud]" + ConnectionUrlFormat.SNOWFLAKE_HOST_SUFFIX)
-            .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
+            .addValidator(StandardValidators.URL_VALIDATOR)

Review Comment:
   Just to clarify then the `.dependsOn(ACCOUNT_IDENTIFIER_FORMAT, AccountIdentifierFormat.FULL_URL)` for that property is not really a URL?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-15261 Added URL/URI validation for properties representing a URL/URI [nifi]

Posted by "dan-s1 (via GitHub)" <gi...@apache.org>.
dan-s1 commented on code in PR #10569:
URL: https://github.com/apache/nifi/pull/10569#discussion_r2567123794


##########
nifi-extension-bundles/nifi-atlassian-bundle/nifi-atlassian-extensions/src/main/java/org/apache/nifi/atlassian/bitbucket/BitbucketFlowRegistryClient.java:
##########
@@ -49,7 +49,7 @@ public class BitbucketFlowRegistryClient extends AbstractGitFlowRegistryClient {
     static final PropertyDescriptor BITBUCKET_API_URL = new PropertyDescriptor.Builder()
             .name("Bitbucket API Instance")
             .description("The Bitbucket API host or base URL (for example, api.bitbucket.org for Cloud or https://bitbucket.example.com for Data Center)")
-            .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
+            .addValidator(StandardValidators.URL_VALIDATOR)

Review Comment:
   In the URL_VALIDATOR there is a regex for a host named `HOST_PATTERN`. Couldn't we have here a custom validator to match either against  a host using that regex (probably cutting and pasting that regex) or matching a URL using the URL_VALIDATOR.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-15261 Added URL/URI validation for properties representing a URL/URI [nifi]

Posted by "dan-s1 (via GitHub)" <gi...@apache.org>.
dan-s1 commented on code in PR #10569:
URL: https://github.com/apache/nifi/pull/10569#discussion_r2567097291


##########
nifi-extension-bundles/nifi-snowflake-bundle/nifi-snowflake-services/src/main/java/org/apache/nifi/snowflake/service/StandardSnowflakeIngestManagerProviderService.java:
##########
@@ -58,7 +58,7 @@ public class StandardSnowflakeIngestManagerProviderService extends AbstractContr
     public static final PropertyDescriptor HOST_URL = new PropertyDescriptor.Builder()
             .name("Snowflake URL")
             .description("Example host url: [account-locator].[cloud-region].[cloud]" + ConnectionUrlFormat.SNOWFLAKE_HOST_SUFFIX)
-            .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
+            .addValidator(StandardValidators.URL_VALIDATOR)

Review Comment:
   Just to clarify that means the `.dependsOn(ACCOUNT_IDENTIFIER_FORMAT, AccountIdentifierFormat.FULL_URL)` for that property is not really a URL?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-15261 Added URL/URI validation for properties representing a URL/URI [nifi]

Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory commented on code in PR #10569:
URL: https://github.com/apache/nifi/pull/10569#discussion_r2567148631


##########
nifi-extension-bundles/nifi-snowflake-bundle/nifi-snowflake-services/src/main/java/org/apache/nifi/snowflake/service/StandardSnowflakeIngestManagerProviderService.java:
##########
@@ -58,7 +58,7 @@ public class StandardSnowflakeIngestManagerProviderService extends AbstractContr
     public static final PropertyDescriptor HOST_URL = new PropertyDescriptor.Builder()
             .name("Snowflake URL")
             .description("Example host url: [account-locator].[cloud-region].[cloud]" + ConnectionUrlFormat.SNOWFLAKE_HOST_SUFFIX)
-            .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
+            .addValidator(StandardValidators.URL_VALIDATOR)

Review Comment:
   Correct, it is not really a URL.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-15261 Added URL/URI validation for properties representing a URL/URI [nifi]

Posted by "dan-s1 (via GitHub)" <gi...@apache.org>.
dan-s1 commented on code in PR #10569:
URL: https://github.com/apache/nifi/pull/10569#discussion_r2567092712


##########
nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/RestLookupService.java:
##########
@@ -95,7 +95,7 @@ public class RestLookupService extends AbstractControllerService implements Reco
                 "not flowfile attributes.")
         .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
         .required(true)
-        .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
+        .addValidator(StandardValidators.URI_LIST_VALIDATOR)

Review Comment:
   That was my bad it should have been `URL_VALIDATOR`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-15261 Added URL/URI validation for properties representing a URL/URI [nifi]

Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory commented on code in PR #10569:
URL: https://github.com/apache/nifi/pull/10569#discussion_r2566998392


##########
nifi-extension-bundles/nifi-snowflake-bundle/nifi-snowflake-services/src/main/java/org/apache/nifi/snowflake/service/StandardSnowflakeIngestManagerProviderService.java:
##########
@@ -58,7 +58,7 @@ public class StandardSnowflakeIngestManagerProviderService extends AbstractContr
     public static final PropertyDescriptor HOST_URL = new PropertyDescriptor.Builder()
             .name("Snowflake URL")
             .description("Example host url: [account-locator].[cloud-region].[cloud]" + ConnectionUrlFormat.SNOWFLAKE_HOST_SUFFIX)
-            .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
+            .addValidator(StandardValidators.URL_VALIDATOR)

Review Comment:
   Although the property name includes `URL`, actual usage does not appear to be a URL, so this change should be reverted.



##########
nifi-extension-bundles/nifi-atlassian-bundle/nifi-atlassian-extensions/src/main/java/org/apache/nifi/atlassian/bitbucket/BitbucketFlowRegistryClient.java:
##########
@@ -49,7 +49,7 @@ public class BitbucketFlowRegistryClient extends AbstractGitFlowRegistryClient {
     static final PropertyDescriptor BITBUCKET_API_URL = new PropertyDescriptor.Builder()
             .name("Bitbucket API Instance")
             .description("The Bitbucket API host or base URL (for example, api.bitbucket.org for Cloud or https://bitbucket.example.com for Data Center)")
-            .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
+            .addValidator(StandardValidators.URL_VALIDATOR)

Review Comment:
   As shown in the description, this can be a host or URL, so the validator change should be reverted.



##########
nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/RestLookupService.java:
##########
@@ -95,7 +95,7 @@ public class RestLookupService extends AbstractControllerService implements Reco
                 "not flowfile attributes.")
         .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
         .required(true)
-        .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
+        .addValidator(StandardValidators.URI_LIST_VALIDATOR)

Review Comment:
   This looks like it should be a single URL, not a URL List?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-15261 Added URL/URI validation for properties representing a URL/URI [nifi]

Posted by "dan-s1 (via GitHub)" <gi...@apache.org>.
dan-s1 commented on PR #10569:
URL: https://github.com/apache/nifi/pull/10569#issuecomment-3584091715

   > Thanks @dan-s1, some of these changes appear to introduce more strict validation than necessary, potentially creating issues. I noted the changes that seemed problematic. Have you evaluated whether these changes support existing configurations, based on unit tests or runtime tests?
   
   I have not evaluated or tested except for the current unit tests which are in place.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] NIFI-15261 Added URL/URI validation for properties representing a URL/URI [nifi]

Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory merged PR #10569:
URL: https://github.com/apache/nifi/pull/10569


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org