GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Storing an Entity as an indexed property value always fails · Issue #529 · googleapis/google-cloud-python

Storing an Entity as an indexed property value always fails #529

New issue
Copy link
New issue
Copy link
Closed
Closed
Storing an Entity as an indexed property value always fails#529
Copy link
Assignees
dhermes
Labels
api: datastoreIssues related to the Datastore API.

Description

@dhermes
dhermes
opened on Jan 9, 2015
Issue body actions

From the spec:

If a value is itself an entity, it cannot have indexed set to true.

This means when the entity_value is added we should set indexed to False on the property. (This is currently not easy, see #403, #404 and #512.)

Or maybe we should just document that users need to add a property name to exclude_from_indexes if that property is an Entity.


To replicate:

>>> import os
>>> from gcloud import datastore
>>> from gcloud.datastore.entity import Entity
>>> from gcloud.datastore.key import Key
>>> 
>>> datastore.set_default_connection()
>>> dataset_id = os.getenv('GCLOUD_TESTS_DATASET_ID')
>>> datastore.set_default_dataset_id(dataset_id)
>>> 
>>> e = Entity(key=Key('Foo', 1))
>>> e2 = Entity(key=Key('Foo', 2))
>>> e['bar'] = e2
>>> e.save()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "gcloud/datastore/entity.py", line 144, in save
    exclude_from_indexes=self.exclude_from_indexes)
  File "gcloud/datastore/connection.py", line 495, in save_entity
    result = self.commit(dataset_id, mutation)
  File "gcloud/datastore/connection.py", line 376, in commit
    datastore_pb.CommitResponse)
  File "gcloud/datastore/connection.py", line 100, in _rpc
    data=request_pb.SerializeToString())
  File "gcloud/datastore/connection.py", line 77, in _request
    raise six.moves.http_client.HTTPException(message)
httplib.HTTPException: Request failed with status code 400.
                       Error was: Entity value is indexed.

and notice it doesn't fail if the property is correctly unindexed:

>>> e = Entity(key=Key('Foo', 1), exclude_from_indexes=('bar',))
>>> e['bar'] = e2
>>> e.save()
>>> e.key.delete()

Activity

Next
  1. dhermes
    added
    api: datastoreIssues related to the Datastore API.
    on Jan 9, 2015
  2. dhermes commented on Jan 9, 2015

    @dhermes
    dhermes
    on Jan 9, 2015
    ContributorAuthor
    More actions

    Note, also setting

    e['foo'] = 'a' * 501

    will cause a failure

    Request failed with status code 400.
    Error was: Indexed blob value has more than permitted 500 bytes.
    

    since the spec states

    When indexed is true, stringValue is limited to 500 characters and the blob value
    is limited to 500 bytes.

    Maybe we are better off just documenting this and letting the users worry about it.

    I think in terms of code complexity, we are better off doing nothing (beyond documentation) and waiting for user feedback.

  3. tseaver commented on Jan 12, 2015

    @tseaver
    tseaver
    on Jan 12, 2015
    Contributor
    More actions

    Is there stuff in the datastore API docs that describes these limitations in detail? I'd rather just point to them, than try to write such docs ourselves.

  4. dhermes commented on Jan 12, 2015

    @dhermes
    dhermes
    on Jan 12, 2015
    ContributorAuthor
    More actions

    @proppy Is there somewhere under https://cloud.google.com/datastore/docs/... that surface the comments from the proto spec?

  5. proppy commented on Jan 12, 2015

    @proppy
    proppy
    on Jan 12, 2015
    Contributor
    More actions

    @dhermes In the API section there is a link to the .proto in the github repo for the current release.
    https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/v1beta2-rev1-2.1.0/proto/datastore_v1.proto

  6. dhermes commented on Jan 12, 2015

    @dhermes
    dhermes
    on Jan 12, 2015
    ContributorAuthor
    More actions

    @proppy Sorry I was unclear.

    I was asking if the user-facing docs actually have sections to match the "docs" from the spec. For example

    When indexed is true, stringValue is limited to 500 characters and the blob value
    is limited to 500 bytes.

    is in the spec, but is it documented anywhere else? Same for

    If a value is itself an entity, it cannot have indexed set to true.

    and other useful information from the spec.

  7. proppy commented on Jan 12, 2015

    @proppy
    proppy
    on Jan 12, 2015
    Contributor
    More actions

    Sorry if I was unclear too :) At first there was a proto API reference that was duplicating the proto comment, but it was removed in a favor of a link to the file in the github repo.

    The JSON API Reference source the doc from the same proto, so in theory https://cloud.google.com/datastore/docs/apis/v1beta2/entity should feature the same comment for the stringValue property description. But for some reason those seems to be missing from this page.

  8. dhermes commented on Jan 12, 2015

    @dhermes
    dhermes
    on Jan 12, 2015
    ContributorAuthor
    More actions

    Thanks. So in general we can point people to those docs for failure cases.

  9. dhermes commented on Jan 14, 2015

    @dhermes
    dhermes
    on Jan 14, 2015
    ContributorAuthor
    More actions

    Deferring this to #532

  10. dhermes
    closed this as completedon Jan 14, 2015
  11. jgeewax
    modified the milestone: This milestone has been deleted on Jan 30, 2015
  12. JustinBeckwith
    assigned
    dhermes
    on Feb 1, 2021
  13. parthea
    added a commit that references this issue on Aug 15, 2023

    fix: Add async context manager return types (#529)

    b74f5d7
  14. parthea
    added a commit that references this issue on Sep 22, 2023

    chore(main): release 5.4.1 (#529)

    bf7d8eb
  15. 4 remaining items

  16. parthea
    added a commit that references this issue on Aug 21, 2025

    feat: add missing_value_interpretations to AppendRowsRequest (#529)

    2ab3fee
  17. parthea
    added 2 commits that reference this issue on Sep 16, 2025

    feat: add missing_value_interpretations to AppendRowsRequest (#529)

    be38510

    docs: fix changelog header to consistent size (#529)

    7091400
  18. parthea
    added 7 commits that reference this issue on Nov 22, 2025

    chore(deps): update actions/download-artifact action to v3 (#529)

    d0c4a87

    chore: release 0.28.0 (#529)

    b80d87f

    chore: avoid checking instance on each stream call (#529)

    4a434ea

    chore: Update gapic-generator-python to v1.23.2 (#529)

    34cf2e2

    chore: use gapic-generator-python 0.62.1 (#529)

    e1bc8cd

    docs: fix type hint for urlsafe (#532)

    33e1c6b

    chore: release 1.17.1 (#529)

    f8c6d52
  19. parthea
    added 4 commits that reference this issue on Mar 2, 2026

    ci: fix IAM samples to avoid block on 'allUsers' (#529)

    a26ae07

    chore(deps): update dependency google-cloud-bigquery-storage to v2.3.0 (

    d0fc9f7

    chore(deps): update dependency grpcio to v1.68.1 (#529)

    1b1d5cc

    fix(deps): add explicit ranges for 'google-api-core' and 'google-auth' (

    007f64e
  20. parthea
    added a commit that references this issue on Sep 8, 2026

    docs: migrate code from googleapis/python-bigquery (#18303)

    23f9a74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @dhermes
    dhermes

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

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.