Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Secretstore broken since 1.13 #1249

Closed
ManuDinicola opened this issue Mar 9, 2024 · 3 comments
Closed

Secretstore broken since 1.13 #1249

ManuDinicola opened this issue Mar 9, 2024 · 3 comments
Assignees
Labels
kind/bug Something isn't working P1
Milestone

Comments

@ManuDinicola
Copy link

Expected Behavior

Expected that the load of secret from a kubernetes/file store works without issue.

Actual Behavior

Since the v1.13, the extension to load secret is broken.

  .AddDaprSecretStore(configuration =>
                {
                    configuration.KeyDelimiters = new List<string>() { ".", "__" };
                    configuration.SecretDescriptors = secretDescriptors;
                    configuration.Store = "kubernetes";
                    configuration.Client = daprClient;
                }
            )

Steps to Reproduce the Problem

Create a simple secret store component
ex :

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: kubernetes
spec:
  type: secretstores.local.file
  version: v1
  metadata:
  - name: secretsFile
    value: C:/Users/emmanuel.dinicola/.dapr/components/secrets.json
  - name: nestedSeparator
    value: ":"
  - name: multiValued
    value: true

Configure the secrets.json like this

{
  "pharma-common": {
    "MyFirstKey": "1",
    "MySecondKey": "2"
  }
}

This problem has been introduced by this #887
Indeed if you look the code that has been changed in DaprSecretStoreConfigurationProvider.cs

         foreach (var key in result.Keys)
                    {
                        if (data.ContainsKey(key))
                        {
                            throw new InvalidOperationException(
                                $"A duplicate key '{key}' was found in the secret store '{store}'. Please remove any duplicates from your secret store.");
                        }

                        data.Add(normalizeKey ? NormalizeKey(secretDescriptor.SecretName) : secretDescriptor.SecretName, result[key]);
                    }

The data.Add will throw error on the second key cause the secretDescriptor.SecretName will not change.

== APP == Unhandled exception. System.ArgumentException: An item with the same key has already been added. Key: pharma-common
== APP ==    at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
== APP ==    at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
== APP ==    at Dapr.Extensions.Configuration.DaprSecretStore.DaprSecretStoreConfigurationProvider.LoadAsync() in D:\GitPR\dotnet-sdk\src\Dapr.Extensions.Configuration\DaprSecretStoreConfigurationProvider.cs:line 232

If we back to the previous code in 1.12 and replace secretDescription.SecretName by key, then no more error.

Release Note

RELEASE NOTE:

@ManuDinicola ManuDinicola added the kind/bug Something isn't working label Mar 9, 2024
@philliphoff philliphoff added the P1 label Mar 11, 2024
@ManuDinicola
Copy link
Author

Is there any chance that will be fixed soon? We want to upgrade to this version that are .net 8 compliant

@yaron2
Copy link
Member

yaron2 commented Apr 15, 2024

Is there any chance that will be fixed soon? We want to upgrade to this version that are .net 8 compliant

We're looking into it. Expect updates soon.

@philliphoff
Copy link
Collaborator

Fixed with #1274 and released as part of v1.13.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working P1
Projects
Development

No branches or pull requests

3 participants