Skip to content

Commit 966574c

Browse files
author
Yuhui Zhong
committed
Fix bug PowerShell returns an exception when listing keys in a vault with 0 keys
1 parent a89ec8b commit 966574c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/ResourceManager/KeyVault/Commands.KeyVault/Models/KeyVaultDataServiceClient.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ public IEnumerable<KeyIdentityItem> GetKeys(KeyVaultObjectFilterOptions options)
192192
result = this.keyVaultClient.GetKeysNextAsync(options.NextLink).GetAwaiter().GetResult();
193193

194194
options.NextLink = result.NextLink;
195-
return result.Value.Select((keyItem) => { return new KeyIdentityItem(keyItem, this.vaultUriHelper); });
195+
return (result.Value == null) ? new List<KeyIdentityItem>() :
196+
result.Value.Select((keyItem) => { return new KeyIdentityItem(keyItem, this.vaultUriHelper); });
196197
}
197198
catch (Exception ex)
198199
{
@@ -349,7 +350,8 @@ public IEnumerable<SecretIdentityItem> GetSecrets(KeyVaultObjectFilterOptions op
349350
result = this.keyVaultClient.GetSecretsNextAsync(options.NextLink).GetAwaiter().GetResult();
350351

351352
options.NextLink = result.NextLink;
352-
return result.Value.Select((secretItem) => { return new SecretIdentityItem(secretItem, this.vaultUriHelper); });
353+
return (result.Value == null) ? new List<SecretIdentityItem>() :
354+
result.Value.Select((secretItem) => { return new SecretIdentityItem(secretItem, this.vaultUriHelper); });
353355
}
354356
catch (Exception ex)
355357
{

0 commit comments

Comments
 (0)