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-75157] Bitbucket client fail to retrieve resource with HTTP 404 for bitbucket server #970

Open
wants to merge 1 commit into
base: 934.3.x
Choose a base branch
from

Conversation

nfalco79
Copy link
Member

Remove the HttpHost parameter when calling in Apache client as it seems to cause a 404 error in the response while in previous version the call worked.

@nfalco79 nfalco79 force-pushed the feature/JENKINS-75157 branch from 1db7ea4 to ff22e1a Compare January 16, 2025 19:41
…404 for bitbucket server

Remove the HttpHost parameter when calling in Apache client as it seems to cause a 404 error in the response while in previous version the call worked.
@nfalco79 nfalco79 force-pushed the feature/JENKINS-75157 branch from ff22e1a to 476a576 Compare January 16, 2025 19:41
@KalleOlaviNiemitalo
Copy link
Contributor

@nfalco79, I was looking at the exception stack traces in https://community.jenkins.io/t/file-not-found-exception-updating-bitbucket-source-plugin-to-latest-version-933-3-0/25724 and comparing to the templating engine implementation in https://github.com/jenkinsci/templating-engine-plugin/blob/2.5.3/src/main/groovy/org/boozallen/plugins/jte/util/FileSystemWrapper.groovy and to https://github.com/jenkinsci/bitbucket-branch-source-plugin/blob/933.3.0/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/impl/client/AbstractBitbucketApi.java. I think what happens is:

  • doRequest gets HTTP status 404 from the server and this is correct because the file does not exist in the repository.
  • doRequest recognizes HttpStatus.SC_NOT_FOUND and throws FileNotFoundException.
  • doRequest catches this FileNotFoundException as IOException and throws another IOException that has the FileNotFoundException as its cause.
  • The JTE FileSystemWrapper does not catch this IOException because it only expects FileNotFoundException.

So the fix should be to make doRequest propagate the FileNotFoundException as is, rather than wrapped in IOException.

I assume this is reproducible with Bitbucket Cloud too, as long as JTE is used and the file does not exist in the repo.

@KalleOlaviNiemitalo
Copy link
Contributor

(I'm not working on the doRequest FileNotFoundException fix myself.)

@KalleOlaviNiemitalo
Copy link
Contributor

KalleOlaviNiemitalo commented Jan 17, 2025

In addition, BitbucketSCMFile.type() could be changed to query the server if the BitbucketSCMFile was created by calling SCMFile.child(String path) and the existence has not been verified yet; see how github-branch-source-plugin does it. This would make SCMFile.exists() return false to the template engine, which then would not call BitbucketSCMFile.content.

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