Skip to content

NIFI-15645 - Fix AzureLogAnalyticsReportingTask wrongly reporting invalid state#10935

Open
pvillard31 wants to merge 3 commits intoapache:mainfrom
pvillard31:NIFI-15645
Open

NIFI-15645 - Fix AzureLogAnalyticsReportingTask wrongly reporting invalid state#10935
pvillard31 wants to merge 3 commits intoapache:mainfrom
pvillard31:NIFI-15645

Conversation

@pvillard31
Copy link
Contributor

Summary

NIFI-15645 - Fix AzureLogAnalyticsReportingTask wrongly reporting invalid state

  • a bit of stylistic cleanup

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

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 contains commits signed with a registered key indicating Verified status

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 according to the License Policy
  • New dependencies are documented in applicable LICENSE and NOTICE files

Documentation

  • Documentation formatting appears as expected in rendered files

@pvillard31 pvillard31 added the bug label Feb 25, 2026
Comment on lines 126 to 132
try {
new URI(MessageFormat.format(input, "workspace-id")).toURL();
return new ValidationResult.Builder().subject(subject).input(input).valid(true).build();
} catch (final Exception e) {
return new ValidationResult.Builder().subject(subject).input(input).valid(false)
.explanation("'%s' is not a valid URL format: %s".formatted(input, e.getMessage())).build();
}
Copy link
Contributor

@dan-s1 dan-s1 Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be written simpler without the try catch.

Suggested change
try {
new URI(MessageFormat.format(input, "workspace-id")).toURL();
return new ValidationResult.Builder().subject(subject).input(input).valid(true).build();
} catch (final Exception e) {
return new ValidationResult.Builder().subject(subject).input(input).valid(false)
.explanation("'%s' is not a valid URL format: %s".formatted(input, e.getMessage())).build();
}
ValidationResult validationResult = StandardValidators.URL_VALIDATOR.validate(subject, MessageFormat.format(input, "workspace-id"), context);
if (validationResult.isValid()) {
return new ValidationResult.Builder().subject(subject).input(input).valid(true).build();
} else {
return new ValidationResult.Builder().subject(subject).input(input).valid(false)
.explanation("'%s' is not a valid URL format: %s".formatted(input, e.getMessage())).build();
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, this is much cleaner

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pvillard31 I made an update as I didn't realize before what you were testing and what you placed in the valid message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants