Skip to content

Commit

Permalink
Add some more debug statements, and validate data length before readi…
Browse files Browse the repository at this point in the history
…ng result
  • Loading branch information
berendhaan committed Jul 9, 2024
1 parent 33f0242 commit 0886fd2
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions extension/task/utils/resolveAzureDevOpsIdentities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,20 @@ async function querySubjectHosted(organization: string, email: string): Promise<
}
});

if (isSuccessStatusCode(response.status)) {
const descriptor: string = response.data.value[0]?.descriptor || "";
const id = decodeBase64(descriptor.substring(descriptor.indexOf(".") + 1))
return {
id: id,
displayName: response.data.value[0]?.displayName,
input: email}
tl.debug(`Got Http Response: ${response.status}`);

if(!isSuccessStatusCode(response.status) || response.data.value.length === 0) {
throw new Error(
'Failed to resolve given email in organization'
);
}

const descriptor: string = response.data.value[0]?.descriptor || "";
const id = decodeBase64(descriptor.substring(descriptor.indexOf(".") + 1))
return {
id: id,
displayName: response.data.value[0]?.displayName,
input: email
}
} catch (error) {
const responseStatusCode = error?.response?.status;
Expand Down

0 comments on commit 0886fd2

Please sign in to comment.