dotnet/aspnetcore

User Secrets broke on different first word capitalization

Open

#8,602 建立於 2019年3月17日

在 GitHub 查看
 (3 留言) (5 反應) (0 負責人)C# (10,653 fork)batch import
affected-fewarea-commandlinetoolsbugfeature-user-secretshelp wantedseverity-minor

倉庫指標

Star
 (37,933 star)
PR 合併指標
 (平均合併 16天 9小時) (30 天內合併 258 個 PR)

描述

Describe the bug

On adding secret key with different first word capitalization, CLI tool fall with unhandled exception until manually fixing secret.json, or changing key Id at csproj

To Reproduce

Steps to reproduce the behavior:

  1. Execute at project DIR commands:
dotnet user-secrets set "ConnectionStrings:DefaultConnection" "test"
dotnet user-secrets set "connectionStrings:DefaultConnection1" "test"
  1. Try to run anything else from user-secrets commands, for example:
dotnet user-secrets list
  1. See error
System.ArgumentException: An item with the same key has already been added. Key: ConnectionStrings:DefaultConnection1
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityCompa
rer`1 comparer)
   at Microsoft.Extensions.SecretManager.Tools.Internal.SecretsStore.Load(String userSecretsId) in /_/src/dotnet-user-secrets/Internal/SecretsSto
re.cs:line 79
   at Microsoft.Extensions.SecretManager.Tools.Internal.SecretsStore..ctor(String userSecretsId, IReporter reporter) in /_/src/dotnet-user-secret
s/Internal/SecretsStore.cs:line 32
   at Microsoft.Extensions.SecretManager.Tools.Program.RunInternal(String[] args) in /_/src/dotnet-user-secrets/Program.cs:line 86
   at Microsoft.Extensions.SecretManager.Tools.Program.TryRun(String[] args, Int32& returnCode) in /_/src/dotnet-user-secrets/Program.cs:line 36
Command failed : An item with the same key has already been added. Key: ConnectionStrings:DefaultConnection1

Expected behavior

Show error on adding, or fixing that issue silently for user

Additional context

.NET Core SDK (reflecting any global.json):
 Version:   2.2.105
 Commit:    7cecb35b92

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.2.105\

Host (useful for support):
  Version: 2.2.3
  Commit:  6b8ad509b6

.NET Core SDKs installed:
  2.1.403 [C:\Program Files\dotnet\sdk]
  2.1.500 [C:\Program Files\dotnet\sdk]
  2.2.105 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

貢獻者指南