From d2509318f85cfd4268581809cd2ef85e1e938d87 Mon Sep 17 00:00:00 2001 From: Wes Haggard Date: Fri, 16 Feb 2024 09:08:44 -0800 Subject: [PATCH] Handle DevOps PAT creation error --- .../ServiceAccountPersonalAccessTokenStore.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/secret-management/Azure.Sdk.Tools.SecretRotation.Stores.AzureDevOps/ServiceAccountPersonalAccessTokenStore.cs b/tools/secret-management/Azure.Sdk.Tools.SecretRotation.Stores.AzureDevOps/ServiceAccountPersonalAccessTokenStore.cs index 80005e34497..ca5f0f49023 100644 --- a/tools/secret-management/Azure.Sdk.Tools.SecretRotation.Stores.AzureDevOps/ServiceAccountPersonalAccessTokenStore.cs +++ b/tools/secret-management/Azure.Sdk.Tools.SecretRotation.Stores.AzureDevOps/ServiceAccountPersonalAccessTokenStore.cs @@ -131,6 +131,10 @@ public override async Task OriginateValueAsync(SecretState currentS PatTokenResult result = await client.CreatePatAsync(new PatTokenCreateRequest { AllOrgs = false, DisplayName = this.patDisplayName, Scope = this.scopes, ValidTo = expirationDate.UtcDateTime }); + if (result.PatTokenError != SessionTokenError.None) { + throw new RotationException($"Unable to create PAT: {result.PatTokenError}"); + } + string authorizationId = result.PatToken.AuthorizationId.ToString(); this.logger.LogInformation("Azure DevOps responded with authorization id '{AuthorizationId}'", authorizationId);