Skip to content

IN operator with __key__ property does not work #15339

Done

Description

@Aiesnow

Hello,
Sorry I'm not 100% if this should be a bug report or a feature request, but since the IN operator is working on the Datastore UI on the GCP Console I'm guessing it's a bug.

Environment details

I'm not allowed to share those, but I don't think it matters in this case

  • OS type and version:
  • Python version: python --version
  • pip version: pip --version
  • google-cloud-datastore version: pip show google-cloud-datastore

Steps to reproduce

  1. Try to execute a query on the __key__ property with the IN operator
  2. Error : ValueError: Invalid key: "[<Key('Kind', 'key'), project=gcp-project>, <Key('Kind', 'key'), project=gcp-project>]"

Code example

query = client.query(kind=kind)
query.add_filter("__key__", "IN", [client.key(kind, key), client.key(kind, key2)])

Stack trace

# example

Sorry I'm not allowed to share the whole stack trace, but I investigated a bit and it seems to come from this condition :

            if property_name == KEY_PROPERTY_NAME and not isinstance(value, Key):
                raise ValueError('Invalid key: "%s"' % value)

In case value is a List, it should check that all elements from the list are Keys instead of raising an error

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

Activity

  1. added
    api: datastore
    on Jul 18, 2025
  2. parthea commented on Jan 12, 2026

    @parthea
    Contributor

    Transferring to google-cloud-python as the code for python-datastore will be migrated there in 1-3 weeks.

  3. added
    type: bug
    priority: p2
    on Nov 13, 2026
  4. daniel-sanche commented on Nov 13, 2026

    @daniel-sanche
    Contributor

    This is being addressed in #19076

  5. daniel-sanche commented on Nov 25, 2026

    @daniel-sanche
    Contributor

    Resolved in #19076, this will be released next week (week of Nov 30)

  6. added a commit that references this issue on Nov 25, 2026
    e40fb36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: datastorepriority: p2type: bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions