components-contrib icon indicating copy to clipboard operation
components-contrib copied to clipboard

panic: interface conversion: interface {} is string, not map[string]interface {}

Open XavierGeerinck opened this issue 2 years ago • 2 comments

When wanting to call a CosmosDB binding I receive the following panic, which I guess happens when 1) partitionKey is not found 2) the data provided is a string

goroutine 408 [running]:
github.com/dapr/components-contrib/bindings/azure/cosmosdb.(*CosmosDB).getPartitionKeyValue(0xc001543c00, {0xc001203d90?, 0x160?}, {0x38bbb80?, 0xc0014f29b0})
        /home/runner/go/pkg/mod/github.com/dapr/[email protected]/bindings/azure/cosmosdb/cosmosdb.go:175 +0x1bc
github.com/dapr/components-contrib/bindings/azure/cosmosdb.(*CosmosDB).Invoke(0xc001543c00, {0xc0014f4c30?, 0x0?}, 0xc0014f4c00)
        /home/runner/go/pkg/mod/github.com/dapr/[email protected]/bindings/azure/cosmosdb/cosmosdb.go:147 +0xb3
github.com/dapr/dapr/pkg/runtime.(*DaprRuntime).sendToOutputBinding.func1({0x4b08e90?, 0xc0011cc840?})
        /home/runner/work/dapr/dapr/pkg/runtime/runtime.go:903 +0x42
github.com/dapr/dapr/pkg/resiliency.(*NoOp).ComponentOutboundPolicy.func1(0x3ad7200?)
        /home/runner/work/dapr/dapr/pkg/resiliency/noop.go:64 +0x27
github.com/dapr/dapr/pkg/runtime.(*DaprRuntime).sendToOutputBinding(0xc00006e300, {0xc0014d7f00, 0xe}, 0xc0014f4c00)
        /home/runner/work/dapr/dapr/pkg/runtime/runtime.go:902 +0x4b7
github.com/dapr/dapr/pkg/http.(*api).onOutputBindingMessage(0xc0011a2780, 0xc0014fa000)
        /home/runner/work/dapr/dapr/pkg/http/api.go:497 +0x649
github.com/dapr/dapr/pkg/http.(*server).unescapeRequestParametersHandler.func1(0xc0014fa000)
        /home/runner/work/dapr/dapr/pkg/http/server.go:303 +0x71
github.com/fasthttp/router.(*Router).Handler(0xc000f54690, 0xc0014fa000)
        /home/runner/go/pkg/mod/github.com/fasthttp/[email protected]/router.go:414 +0x46a
github.com/dapr/dapr/pkg/diagnostics.(*httpMetrics).FastHTTPMiddleware.func1(0xc0014fa000)
        /home/runner/work/dapr/dapr/pkg/diagnostics/http_monitoring.go:195 +0x13b
github.com/dapr/dapr/pkg/diagnostics.HTTPTraceMiddleware.func1(0xc0014fa000)
        /home/runner/work/dapr/dapr/pkg/diagnostics/http_tracing.go:56 +0xef
github.com/valyala/fasthttp.(*Server).serveConn(0xc00057e000, {0x4b1a9f8?, 0xc00148cfa8})
        /home/runner/go/pkg/mod/github.com/valyala/[email protected]/server.go:2293 +0x1268
github.com/valyala/fasthttp.(*workerPool).workerFunc(0xc0015c0d20, 0xc00199b3c0)
        /home/runner/go/pkg/mod/github.com/valyala/[email protected]/workerpool.go:223 +0xa9
github.com/valyala/fasthttp.(*workerPool).getCh.func1()
        /home/runner/go/pkg/mod/github.com/valyala/[email protected]/workerpool.go:195 +0x38
created by github.com/valyala/fasthttp.(*workerPool).getCh
        /home/runner/go/pkg/mod/github.com/valyala/[email protected]/workerpool.go:194 +0x1b0

This happens when a component is defined like this:

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: binding-result
spec:
  type: bindings.azure.cosmosdb
  version: v1
  metadata:
  - name: url
    value: https://MASKED.documents.azure.com:443/
  - name: masterKey
    value: MASKED
  - name: database
    value: MASKED
  - name: collection
    value: items
  - name: partitionKey
    value: customerId

Attaching the respective line that breaks:

https://github.com/dapr/components-contrib/blob/bcea284c7b0c1a5a07294021a2bb6cc74909da35/bindings/azure/cosmosdb/cosmosdb.go#L149

XavierGeerinck avatar Sep 05 '22 16:09 XavierGeerinck

Which version of Dapr?

artursouza avatar Sep 06 '22 21:09 artursouza

1.8

Get Outlook for iOShttps://aka.ms/o0ukef


From: Artur Souza @.> Sent: Tuesday, September 6, 2022 11:14:27 PM To: dapr/components-contrib @.> Cc: Xavier Geerinck @.>; Author @.> Subject: Re: [dapr/components-contrib] panic: interface conversion: interface {} is string, not map[string]interface {} (Issue #2051)

Which version of Dapr?

— Reply to this email directly, view it on GitHubhttps://github.com/dapr/components-contrib/issues/2051#issuecomment-1238655677, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAEQLMX57PCHHTQG5ZGY3S3V46X3HANCNFSM6AAAAAAQFD524M. You are receiving this because you authored the thread.Message ID: @.***>

XavierGeerinck avatar Sep 06 '22 21:09 XavierGeerinck

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.

dapr-bot avatar Oct 06 '22 21:10 dapr-bot

👋

mukundansundar avatar Oct 07 '22 02:10 mukundansundar

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.

dapr-bot avatar Nov 06 '22 03:11 dapr-bot

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue, help wanted or triaged/resolved. Thank you for your contributions.

dapr-bot avatar Nov 13 '22 03:11 dapr-bot

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue, help wanted or triaged/resolved. Thank you for your contributions.

dapr-bot avatar Nov 20 '22 04:11 dapr-bot