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

[JENKINS-64418] Fix duplicate base URL in request to Bitbucket Server #959

Merged
merged 1 commit into from
Jan 6, 2025

Conversation

KalleOlaviNiemitalo
Copy link
Contributor

@KalleOlaviNiemitalo KalleOlaviNiemitalo commented Jan 5, 2025

Commit e4d32d5 (#927 for JENKINS-64418) introduced a bug that duplicates the base URL in some HTTP requests to Bitbucket Server, causing an error like this:

java.io.FileNotFoundException: URL: https://bitbucket.examplehttps://bitbucket.example/rest/api/1.0/projects/DEMO/repos/demo/branches?filterText=master&start=0&limit=200
	at com.cloudbees.jenkins.plugins.bitbucket.impl.client.AbstractBitbucketApi.doRequest
java.io.IOException: Communication error for url: GET https://bitbucket.examplehttps://bitbucket.example/rest/api/1.0/projects/DEMOrepos/demo/branches?filterText=master&start=0&limit=200 HTTP/1.1
	at com.cloudbees.jenkins.plugins.bitbucket.impl.client.AbstractBitbucketApi.doRequest
	at com.cloudbees.jenkins.plugins.bitbucket.impl.client.AbstractBitbucketApi.getRequest
	at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getResource
	at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getSingleBranch
	at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getBranch
	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.retrieve
	at jenkins.scm.api.SCMSource.fetch

The problem is that getSingleBranch prepends this.baseURL to the URI template and calls getResource, which expands the template and prepends this.baseURL to the resulting URL again.

getResource is called only by getSingleTag and getSingleBranch, and both of them include the base URL in the template. Thus, getResource should not prepend it again.

Your checklist for this pull request

  • Make sure you are requesting to pull a topic/feature/bugfix branch (right side) and not your master branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or in Jenkins JIRA
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Did you provide a test-case? That demonstrates feature works or fixes the issue.

Commit e4d32d5 (for JENKINS-64418)
introduced a bug that duplicates the base URL in some HTTP requests
to Bitbucket Server, causing an error like this:

java.io.FileNotFoundException: URL: https://bitbucket.examplehttps://bitbucket.example/rest/api/1.0/projects/DEMO/repos/demo/branches?filterText=master&start=0&limit=200
	at com.cloudbees.jenkins.plugins.bitbucket.impl.client.AbstractBitbucketApi.doRequest
java.io.IOException: Communication error for url: GET https://bitbucket.examplehttps://bitbucket.example/rest/api/1.0/projects/DEMOrepos/demo/branches?filterText=master&start=0&limit=200 HTTP/1.1
	at com.cloudbees.jenkins.plugins.bitbucket.impl.client.AbstractBitbucketApi.doRequest
	at com.cloudbees.jenkins.plugins.bitbucket.impl.client.AbstractBitbucketApi.getRequest
	at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getResource
	at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getSingleBranch
	at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getBranch
	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.retrieve
	at jenkins.scm.api.SCMSource.fetch

The problem is that getSingleBranch prepends this.baseURL to the URI
template and calls getResource, which expands the template and
prepends this.baseURL to the resulting URL again.

getResource is called only by getSingleTag and getSingleBranch, and
both of them include the base URL in the template.
Thus, getResource should not prepend it again.
@KalleOlaviNiemitalo
Copy link
Contributor Author

The latest release 933.2.0 was made before the bug was introduced.

@KalleOlaviNiemitalo
Copy link
Contributor Author

@nfalco79 should I file a separate issue for this even though the bug has not been released yet? Or will the fix go in as part of the JENKINS-64418 implementation?

@nfalco79
Copy link
Member

nfalco79 commented Jan 5, 2025

@nfalco79 should I file a separate issue for this even though the bug has not been released yet? Or will the fix go in as part of the JENKINS-64418 implementation?

No needed, you can refer the same jenkins issue. I normally release after 1/2 weeks it works in our production

@KalleOlaviNiemitalo
Copy link
Contributor Author

The commit title format [JENKINS-XYZ] <Issue Title> that you requested in #940 (comment) feels unsuitable to this, when this PR is not adding a backoff loop.

@nfalco79
Copy link
Member

nfalco79 commented Jan 5, 2025

Does matter I will change the title and comment on merge

@KalleOlaviNiemitalo KalleOlaviNiemitalo changed the title Fix duplicate base URL in request to Bitbucket Server [JENKINS-64418] Fix duplicate base URL in request to Bitbucket Server Jan 5, 2025
@KalleOlaviNiemitalo
Copy link
Contributor Author

Tested that building a branch works OK with commit 539c964.

Didn't test building a tag yet.

@nfalco79 nfalco79 marked this pull request as ready for review January 6, 2025 00:37
@nfalco79 nfalco79 self-requested a review January 6, 2025 00:38
@nfalco79 nfalco79 merged commit c8722d2 into jenkinsci:master Jan 6, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants