Closed bjornbm closed 4 years ago
Hmm... is the nickname vs username difference documented anywhere on bitbucket? I'd like to understand the difference better before pulling this in
The problem I was having was that I got an error message regarding the username
not being a field of the user object. Inspecting the user object it seemed nickname
was the closest thing available.
See https://developer.atlassian.com/cloud/bitbucket/bitbucket-api-changes-gdpr. In particular
The short summary is that username endpoints and username fields will stop being available on 29 April 2019, and we're introducing some new data points that are available immediately to replace them.
and
In all cases where Bitbucket APIs return user details, we are introducing two new fields to the object body, Atlassian account ID account_id and nickname.
Thanks for digging that up.
Reading through the linked doc, I noticed that:
display_name
for the places where we were accessing their username
field.display_name
is always guaranteed to have some value, but do not make that promise about nickname
.nickname
is not guaranteed to be unique. I'm guessing display_name
isn't either though.Given the above, would display_name
be more appropriate than nickname
? I have not played with the API so I don't know if it actually returns this... sometimes docs do not match reality.
Here is a user as passed to format_user
of migrate.py
:
{
'display_name': 'Björn Buckwalter',
'uuid': '{647e413e-1269-4aec-912f-9e214acb1df7}',
'links': {
'self': {'href': 'https://api.bitbucket.org/2.0/users/%7B647e413e-1269-4aec-912f-9e214acb1df7%7D'},
'html': {'href': 'https://bitbucket.org/%7B647e413e-1269-4aec-912f-9e214acb1df7%7D/'},
'avatar': {'href': 'https://avatar-cdn.atlassian.com/557058%3A4d58b2d4-edfd-4232-9dc6-8cf28044ca15?by=id&sg=RyTjFmqMnVDGE99Y8FOwSaiPt24%3D&d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FBB-0.png'}
},
'nickname': 'bjornbm',
'type': 'user',
'account_id': '557058:4d58b2d4-edfd-4232-9dc6-8cf28044ca15'
}
Here are lines 658–661 of migrate.py
:
bb_user = "Bitbucket: [{0}](https://bitbucket.org/{0})".format(user['nickname'])
gh_username = _gh_username(user['nickname'], options.users, options.gh_auth)
if gh_username is not None:
gh_user = "GitHub: [{0}](https://github.com/{0})".format(gh_username)
Observations:
nickname
(assuming the user
reused their Bitbucket username on GitHub as per README.md
).display_name
both Bitbucket and Github URLs are broken. uuid
can be used to construct a Bitbucket URL (https://bitbucket.org/%7B647e413e-1269-4aec-912f-9e214acb1df7%7D/ in this case) but clearly is not useful for constucting a Github URL.Thanks! And sorry about this--I totally forgot about it
I had to make this change for the migration to work. It seemed like the right thing to do and the results of a migration look fine to me.