dapr / js-sdk

Dapr SDK for Javascript
Apache License 2.0
192 stars 80 forks source link

Fetching Keys from Azure App Config using metadata.label not returning appropriate response. #570

Closed dbauswel closed 5 months ago

dbauswel commented 5 months ago

Fetching Keys from Azure App Configuration using metadata.label field does not work. Currently receiving a 404 response. code snippet attached.

const config = await client.configuration.get(
            'azureappconfig',
            [key1],
            {
                metadata: {
                    label: yourEnv
                }
            }
        )

Note that making a direct call works. /v1.0/configuration/azureappconfig?key=key1&metadata.label=yourEnv

shubham1172 commented 5 months ago

Hi @dbauswel, the HTTP DaprClient does not support configuration so I guess you meant the gRPC DaprClient is throwing a not-found error? Are you able to make a direct gRPC request and get this data?

tlund101 commented 5 months ago

Hi @dbauswel, the HTTP DaprClient does not support configuration so I guess you meant the gRPC DaprClient is throwing a not-found error? Are you able to make a direct gRPC request and get this data?

@shubham1172 I'm familiar with the issue, and this is correct. Both GetConfiguration and GetConfigurationAlpha1 from the proto file correctly return a key with the matching metadata label via gRPC request. Trying to use the gRPC DaprClient seems to ignore the metadata and returns a matching key without a label (if there is one, otherwise it logs a 404 error).

Passing an empty array to fetch all keys returns them all, and those that have labels show them in the metadata field that is returned.

shubham1172 commented 5 months ago

Thanks for the insight @tlund101, it looks like it's the way the metadata is being passed.

Non-working scenario https://github.com/dapr/js-sdk/blob/5c2b40ac94b50f6a5bdb32008f6a47da69946d95/src/implementation/Client/GRPCClient/configuration.ts#L59

Working scenario https://github.com/dapr/js-sdk/blob/5c2b40ac94b50f6a5bdb32008f6a47da69946d95/src/implementation/Client/GRPCClient/state.ts#L142

We need to change it. Please let me know if any of you want to create a PR, else I will create one.

tlund101 commented 5 months ago

Looks pretty straightforward, I'll take a look at it and test it on our end.