Skip to content

datastore: equal keys in different namespaces are deduped incorrectly #7829

@maros7

Description

@maros7

Client

Datastore

Environment

Any...

Go Environment

$ go version
go version go1.20.3 darwin/arm64
$ go env

Code

ks := k.String()
if _, ok := keyMap[ks]; !ok {
pbKeys = append(pbKeys, keyToProto(k))
}
keyMap[ks] = append(keyMap[ks], i)

Let's say I have...

  • Entity 1: Kind: A, Name: B, Namespace: NS1
  • Entity 2: Kind: A, Name: B, Namespace: NS2

...then the second one will be deduped in the code above since namespace is not taken into consideration. Meaning that pbKeys is not complete.

Expected behavior

Both keys should be added to pbKeys.

Actual behavior

image

image

As one can see above. Index 1 and 2 in keys are just index 1 in pbKeys due to the fact that they share the same string representation.

Additional context

N/A

Metadata

Metadata

Assignees

Labels

api: datastoreIssues related to the Datastore API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions