feat(bitbucketdatacenter): allow service accounts to not require user setup#2726
Conversation
|
|
There was a problem hiding this comment.
Code Review
This pull request updates the Bitbucket Data Center provider to allow authentication without an explicitly defined user by falling back to a direct repository URL request for token validation. Feedback from the review highlights a critical need for a nil check on the repository object to prevent runtime panics. Furthermore, the current error handling logic needs refinement to avoid malformed error strings when wrapping nil errors and to provide more accurate messaging when the user field is empty.
645ee48 to
afb412f
Compare
mathur07
left a comment
There was a problem hiding this comment.
/lgtm
cc: @zakisk @theakshaypant
|
/ok-to-test |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2726 +/- ##
=======================================
Coverage 59.73% 59.73%
=======================================
Files 210 210
Lines 21112 21117 +5
=======================================
+ Hits 12611 12615 +4
- Misses 7706 7707 +1
Partials 795 795 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@Ru13en what do you mean by service account? do you mean repo http access token as you added in PR description? |
|
@zakisk, correct. Bitbucket DC has 3 types of HTTPS tokens. User tokens have the authentication attached to the Licensed user. Repository HTTPS token and Project HTTPS have the authentication integrated within the server and can be used as Service Account. There is no need to have an extra Bitbucket User license, when the Project and Repo token can create webooks, create repositories (for project token), commits and comments. |
|
@Ru13en I've tested this and found that you can actually use project access token with admin permission in PaC without any code changes but for repo access token we need to LICENCED_USER for checking permission of the user pushing to repo or raising PR. |
@zakisk HTTP repository tokens with admin permission can get the members of the group necessary to check the permissions that you mention. Try with the following command:
Also they can get all permissions of the repository that it belongs.
When you setup the scm-go client, if you don't drop the user, you will be forced to add an known user as a placeholder for the Repository PAC config and then this username somehow is being used... |
|
@Ru13en yeah, you're right I tried it. but you don't need to do the changes you're doing at the moment. it's issue in ACL when org membership check fails due to lack of permission on repo http token, it's returning right from there without checking below repo collaborator permission so you can just have a condition like this to get repo token working fine: but your token must be having repo admin permission |
|
@zakisk these changes are only to drop the unnecessary requirement for a username if I provide a HTTP Token during the PaC Repository configuration, since you are forced to add a valid one. |
|
but if its working with repo and project access token why do you wanna remove user account check? |
|
When you add the Repo config via GitOps we use External Secrets to inject the HTTP Tokens. |
it was implemented a while ago in this commit to ensure that token is valid 549b2d8 |
it makes sense after you explained your use case! |
afb412f to
279d636
Compare
|
/ok-to-test |
|
@Ru13en please refine docs changes and we're good to go with it... |
567d993 to
4c61450
Compare
|
Made the changes as requested @zakisk |
d21c0db to
f1c5842
Compare
|
/agentic_review |
|
/ok-to-test |
f1c5842 to
ceb5666
Compare
|
/ok-to-test |
|
too many E2E failures... 😕 @Ru13en BTW, it's not your PR. we're working for tests fixing |
ceb5666 to
0df0db6
Compare
|
/ok-to-test |
… in the set client
0df0db6 to
01593b5
Compare
|
/ok-to-test |
|
/retest |
|
@Ru13en Thank you for contributing! 🎉 |

📝 Description of the Change
Previously, using project or repository HTTP scoped tokens required configuring an associated user, even when the token already provided the necessary access context.
This PR removes the requirement to configure a user when using HTTP tokens from project and repository scopes.
It updates authentication flow to rely directly on the scoped token context, when only token is provided.
Related validation and tests were adjusted accordingly
🔗 Linked GitHub Issue
Fixes #
#2685
🧪 Testing Strategy
🤖 AI Assistance
AI assistance can be used for various tasks, such as code generation,
documentation, or testing.
Please indicate whether you have used AI assistance
for this PR and provide details if applicable.
Important
Slop will be simply rejected, if you are using AI assistance you need to make sure you
understand the code generated and that it meets the project's standards. you
need at least know how to run the code and deploy it (if needed). See
startpaac to make it easy
to deploy and test your code changes.
If the majority of the code in this PR was generated by an AI, please add a
Co-authored-bytrailer to your commit message.For example:
Co-authored-by: Claude noreply@anthropic.com
✅ Submitter Checklist
fix:,feat:) matches the "Type of Change" I selected above.make testandmake lintlocally to check for and fix anyissues. For an efficient workflow, I have considered installing
pre-commit and running
pre-commit installtoautomate these checks.