Skip to content

[JENKINS-38608] Fix to allow null value in 'GIT_URL_n' #820

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

Closed

Conversation

rishabhBudhouliya
Copy link
Contributor

@rishabhBudhouliya rishabhBudhouliya commented Jan 21, 2020

JENKINS-38608

Screenshot 2020-01-22 at 1 15 44 AM

The issue belongs to the Source Code Management section, whereupon the addition of a secondary repository URL and leaving it empty caused something like this java.lang.IllegalArgumentException: Null value not allowed as an environment variable: GIT_URL_2.

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that verify my changes
  • Unit tests pass locally with my changes
  • I have added documentation as necessary
  • No Javadoc warnings were introduced with my changes
  • No spotbugs warnings were introduced with my changes
  • I have interactively tested my changes
  • Any dependent changes have been merged and published in upstream modules (like git-client-plugin)

Types of changes

What types of changes does your code introduce? Put an x in the boxes that apply. Delete the items in the list that do not apply

  • Bug fix (non-breaking change which fixes an issue)

@jglick jglick removed their request for review January 21, 2020 20:32
@MarkEWaite MarkEWaite added bugfix Fixes a bug - used by Release Drafter gsoc Google Summer of Code contribution labels Jan 21, 2020
Copy link
Contributor

@MarkEWaite MarkEWaite left a comment

Choose a reason for hiding this comment

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

Additional white space changes that I think are needed.

@MarkEWaite
Copy link
Contributor

MarkEWaite commented Jan 22, 2020

Thanks for the submission. I had time to do a more detailed code review tonight and wanted to provide you the results of the code review.

I think that the root of the problem is that the repository URL should never be allowed to be null. A UserRemoteConfig with a null repository is not usable for any clone because there is no repository to clone. However, changing the rules for nullability of the URL of a UserRemoteConfig would likely affect compatibility in many places for many users. I am unwilling to take that risk because there are 250 000 installations of the git plugin and compatibility is very important to those installations.

Since I'm unwilling to take the risk of changing the nullabilty of the UserRemoteConfig URL, I think we should improve the error message so that the user understands the mistake they made. Instead of reporting that an environment variable cannot be null, let's tell them that the repository URL cannot be empty.

I also found that the same condition exists if the first repository URL in the job definition is empty. Since the same conditions exist for both the first and any subsequent repository URL's, it seemed safe to insert a check before the assignment of the environment variables.

I've pushed proposed changes to the pull request to a branch in my fork of the git plugin.

Thanks very, very much for proposing this pull request. Would you be willing to review the changes I made and apply the subset you think makes sense into your pull request? I'm perfectly fine if you disagree with something I've done and decide that it needs to be done in a better way.

Copy link
Contributor

@MarkEWaite MarkEWaite left a comment

Choose a reason for hiding this comment

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

Review the comments and code changes in my branch and decide if there is a better way to approach it than I've attempted there.

@fcojfernandez
Copy link
Member

I agree with @MarkEWaite. I don't see the current message as understandable or even informative. I have also concerns about side-effects if we just don't set the environment variable, so I my vote here is for giving a better message to users so they can fix the job configuration.

@rishabhBudhouliya
Copy link
Contributor Author

@MarkEWaite Yes, I definitely agree with the proposed solution, I was not aware of the consequences of allowing a null value in UserRemoteConfig, and clearly I need a better understanding of the plugin.

The only issue I feel here is that from a user perspective, the save button should not allow submission if the Repository URL is left empty. For now, I can't figure out a way to make the field mandatory.

@rishabhBudhouliya
Copy link
Contributor Author

@MarkEWaite I have reviewed the code and commented on the individual commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fixes a bug - used by Release Drafter gsoc Google Summer of Code contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants