FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Cloud Spanner client incorrectly handles NOT_FOUND error returned by create database · Issue #4071 · googleapis/google-cloud-python · GitHub

Cloud Spanner client incorrectly handles NOT_FOUND error returned by create database #4071

Description

While creating a database, is the backend returns NOT_FOUND error, the client assumes it to indicate that instance is not found and thus returns "Instance not found" error message:
https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/spanner/google/cloud/spanner_v1/database.py#L213

This is not always the case as cloud spanner can return NOT_FOUND in other scenarios. For eg in the "CREATE INDEX ... " ddl statement that table that the index is being created on does not exist it would return a NOT_FOUND. I think the fix would be to just pass the error message returned by the rpc to the user.

This can be reproduced using:

from google.cloud import spanner

"""Creates a database and tables for pattern 1 sample data."""

spanner_client = spanner.Client()

instance = spanner_client.instance("test-instance")



database = instance.database("bitemporal_pattern1", ddl_statements=[

    """CREATE TABLE MyTable (

        Id        String(36) NOT NULL,

        Field1  STRING(36) NOT NULL

) PRIMARY KEY (Id)"""

,

"""CREATE INDEX IDX ON yTable (Field1)"""

])



operation = database.create()



print('Waiting for operation to complete...')

operation.result()

Metadata

Metadata

Labels

api: spannerIssues related to the Spanner API.priority: p2Moderately-important priority. Fix may not be included in next release.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


Back | FazBrowse Home | New Git URL