Skip to content

Datastore: When runQuery fails with index required, the exact index needed should be part of the error message. #1090

Description

@krisnye

This is the current error message when a required index is not found:

ApiError: Precondition Failed - no matching index found.

Many lives would be immeasurably improved if the error looked more like this:

ApiError: Precondition Failed - no matching index found.
    Solution: You must add the following index to your index.yaml file:
        - kind: Cat
          ancestor: no
          properties:
          - name: name
          - name: age
            direction: desc
    For more info, see: https://cloud.google.com/sdk/gcloud/reference/preview/datastore/create-indexes

Activity

  1. changed the title [-]Datastore.runQuery: When fails with index required, the exact index needed should be part of the error message.[/-] [+]Datastore: When runQuery fails with index required, the exact index needed should be part of the error message.[/+] on Jan 26, 2016
  2. krisnye commented on Jan 26, 2016

    @krisnye
    Author

    For instance, this is the query I am currently trying to run:

    {
        "namespace":null,
        "kinds":["Task"],
        "filters":[
            {
                "name":"__key__",
                "op":"HAS_ANCESTOR",
                "val":{
                    "name":"9CDFB82D-FC98-2B7F-22C5-A391A0623474",
                    "kind":"Project",
                    "path":["Project","9CDFB82D-FC98-2B7F-22C5-A391A0623474"]
                }
            },
            {"name":"parentId =","op":"=","val":"9"}
        ],
        "orders":[{"name":"order","sign":"+"}],
        "groupByVal":[],
        "selectVal":[],
        "autoPaginateVal":true,
        "startVal":null,
        "endVal":null,
        "limitVal":-1,
        "offsetVal":-1
    }
    

    I get the Error that no matching index is found.
    My application has the following index specified:

    Task
    Includes ancestors parentId ▲ + order ▲

    This leaves me unsure of what the problem is, or what index I need to add.

  3. stephenplusplus commented on Jan 27, 2016

    @stephenplusplus
    Contributor

    @pcostell - is it possible/reliable to generate such an error message given the query object and 412 response?

  4. pcostell commented on Jan 27, 2016

    @pcostell
    Contributor

    Yup this has been a rough experience. We are working on adding this to the server error message, so as long as you pass along the error message this should start working soon.

  5. stephenplusplus commented on Jan 29, 2016

    @stephenplusplus
    Contributor

    Cool, that will be a great addition! We pass the raw API message, so the user will get it when it's available.

  6. added a commit that references this issue on Sep 4, 2025
  7. added a commit that references this issue on Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api: datastoreIssues related to the Datastore API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions