microsoft / azure-devops-extension-sdk

Client SDK for developing Azure DevOps extensions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom Forms Control is missing the user descriptor on `SDK.getUser()`

matthid opened this issue · comments

In our custom form controls we noticed that the member IUserContext.descriptor is somehow missing from the SDK.getUser() object.
We want to use the descriptor to get membership information from the API of the current user (for a UI-only block).

What we do get is an object similar to this:

{
  displayName: "Full Name",
  id: "0000000-0000-1000-0000-000000000000",
  imageUrl: "https://dev.azure.com/<instance>/_apis/GraphProfile/MemberAvatars/aad.MDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDA=",
  name: "Full.Name@domain.tld"
}

As our extension has different contributions, we can see that on others (for example a project/organization settings page contributions) we get the descriptor:

{
  descriptor: "aad.MDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDA=",
  displayName: "Full Name",
  id: "0000000-0000-1000-0000-000000000000",
  imageUrl: "https://dev.azure.com/<instance>/_apis/GraphProfile/MemberAvatars/aad.MDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDA=",
  name: "Full.Name@domain.tld"
}

However, it seems to be missing on custom form controls...

As this is not documented (the TypeScript type says the field is always there) and I don't see any other good way, I assume this is a Bug. We could:

  • parse imageUrl
  • compare the data with the full list of users) to get the current user context.
  • creating the descriptor ourself from the id-entry but for some reason the Ids differ (as in the anonymized example above).

We would love to hear a workaround or an alternative approach to solve the problem at hand with the SDK or other REST calls.