google-cloud-go icon indicating copy to clipboard operation
google-cloud-go copied to clipboard

fix(firestore): Support any type where `reflect.Kind == String` in map keys

Open Tatskaari opened this issue 3 months ago • 1 comments

Looks like this gets checked in toProtoValue() but converting via value.Interface().(string) will fail for types defined with type Foo string:

     | panic: interface conversion: interface {} is Foo, not string [recovered, repanicked]
     | goroutine 113 [running]:
     | testing.tRunner.func1.2({0x100bf9540, 0x14000482e10})
     |  /Users/jpoole/sdk/go1.25.0/src/testing/testing.go:1872 +0x190
     | testing.tRunner.func1()
     |  /Users/jpoole/sdk/go1.25.0/src/testing/testing.go:1875 +0x31c
     | panic({0x100bf9540?, 0x14000482e10?})
     |  /Users/jpoole/sdk/go1.25.0/src/runtime/panic.go:783 +0x120
     | cloud.google.com/go/firestore.extractTransformsFromMap({0x100c11de0?, 0x140002860d8?, 0x1400046d618?}, {0x140000444b0, 0x1, 0x10093d3fc?})
     |  /Users/jpoole/go/pkg/mod/cloud.google.com/go/[email protected]/document.go:226 +0x654

Given we already know type.Kind() == reflect.String we can just call value.String() to get the string value.

Tatskaari avatar Sep 15 '25 14:09 Tatskaari

Please resolve merge conflicts

bhshkh avatar Oct 17 '25 20:10 bhshkh