Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spike: Do not validate licenseFile and licenseText values to prevent startup issues #7061

Closed
wants to merge 5 commits into from

Conversation

ramonsmits
Copy link
Member

@ramonsmits ramonsmits commented Jun 7, 2024

Do not validate licenseFile and licenseText values to prevent startup issues due to invalid values

Resolves:

No technical limitations are enforced at runtime when either no license is found or a license has expired.

Source: https://docs.particular.net/nservicebus/licensing/#throughput-limitations

@ramonsmits ramonsmits self-assigned this Jun 7, 2024
Copy link
Contributor

@SeanFeldman SeanFeldman left a comment

Choose a reason for hiding this comment

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

This may not be the right approach.
Let's assume I'm unintentionally providing content that is considered an invalid license, thinking it's right. How will I find out my license content differs from what I think it is?
I'd appreciate it if you could have a warning log.

Copy link
Member

@johnsimons johnsimons left a comment

Choose a reason for hiding this comment

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

@ramonsmits in the issue referenced, it seems the user is explicitly calling the API, which in this case is throwing an exception.
If the user wants to handle a scenario where the license string may be empty or null, then they have to handle that themselves before calling the API.

In other words, I think the validation error is correct and should not be removed.

@jpalac
Copy link
Contributor

jpalac commented Jun 10, 2024

It feels like if you're specifically using endpointConfiguration.LicensePath("PathToLicense") then you intend to provide a path to a license file. If you do not have a path, then do not make the API call.
If a path is provided but it is invalid (doesn't exist) or the license found at the path is invalid or expired, then the code works as expected.

@ramonsmits
Copy link
Member Author

The documentation states:

No technical limitations are enforced at runtime when either no license is found or a license has expired.

However, this API is an explicit call. It is expected that some data to process is present.

@ramonsmits ramonsmits closed this Jun 10, 2024
ArgumentNullException.ThrowIfNull(config);
ArgumentException.ThrowIfNullOrWhiteSpace(licenseFile);

// Intentionally not doing validation as passed value could be dynamic and (temporarily) be invalid
Copy link
Member Author

Choose a reason for hiding this comment

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

What is strange here is that currently we do not do a File.Exist. If we defer that we could also defer ANY validation. However, now including a File.Exist is a breaking change.

Copy link
Member

Choose a reason for hiding this comment

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

It is a tricky situation, it may be nice to involve others to see their thoughts

@ramonsmits ramonsmits reopened this Jun 12, 2024
@ramonsmits
Copy link
Member Author

I'm not satisfied with these changes. Too big diff for what we want.

Alternative is to just add validation in the extension methods and use

LogManager.GetLogger<LicenseManager>().Error("LicensePath argument is invalid and will be ignored")

Problem with that is that although no ArgumentException is raised the behavior will be different as now we will scan a bunch of default locations for the presence of a license file.

@johnsimons johnsimons closed this Jun 13, 2024
@ramonsmits ramonsmits changed the title Do not validate licenseFile and licenseText values to prevent startup issues Spike: Do not validate licenseFile and licenseText values to prevent startup issues Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants