-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
api: spannerIssues related to the Spanner API.Issues related to the Spanner API.backendexternalThis issue is blocked on a bug with the actual product.This issue is blocked on a bug with the actual product.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-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.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
When an invalid (non-existent) instance id is specified the error you receive isn't intuitive.
spanner_client = spanner.Client()
# Get an instance, but provide a non-existent instance id
instance = spanner_client.instance('non_existent_spanner_instance')
database = instance.database('real_database_id_on_different_instance')
with database.snapshot() as snapshot:
results = snapshot.execute_sql('SELECT 1')
for row in results:
print(row)
Expected
An error indicating my instance doesn't exist.
Actual
google.api_core.exceptions.InvalidArgument: 400 Invalid CreateSession request.
File "/usr/local/google/home/donghuiz/.local/lib/python2.7/site-packages/google/cloud/spanner_v1/database.py", line 499, in __enter__
session = self._session = self._database._pool.get()
File "/usr/local/google/home/donghuiz/.local/lib/python2.7/site-packages/google/cloud/spanner_v1/pool.py", line 268, in get
session.create()
File "/usr/local/google/home/donghuiz/.local/lib/python2.7/site-packages/google/cloud/spanner_v1/session.py", line 116, in create
session_pb = api.create_session(self._database.name, metadata=metadata, **kw)
File "/usr/local/google/home/donghuiz/.local/lib/python2.7/site-packages/google/cloud/spanner_v1/gapic/spanner_client.py", line 290, in create_session
request, retry=retry, timeout=timeout, metadata=metadata
File "/usr/local/google/home/donghuiz/.local/lib/python2.7/site-packages/google/api_core/gapic_v1/method.py", line 143, in __call__
return wrapped_func(*args, **kwargs)
File "/usr/local/google/home/donghuiz/.local/lib/python2.7/site-packages/google/api_core/retry.py", line 273, in retry_wrapped_func
on_error=on_error,
File "/usr/local/google/home/donghuiz/.local/lib/python2.7/site-packages/google/api_core/retry.py", line 182, in retry_target
return target()
File "/usr/local/google/home/donghuiz/.local/lib/python2.7/site-packages/google/api_core/timeout.py", line 214, in func_with_timeout
return func(*args, **kwargs)
File "/usr/local/google/home/donghuiz/.local/lib/python2.7/site-packages/google/api_core/grpc_helpers.py", line 59, in error_remapped_callable
six.raise_from(exceptions.from_grpc_error(exc), exc)
File "/usr/lib/python2.7/dist-packages/six.py", line 737, in raise_from
raise value
google.api_core.exceptions.InvalidArgument: 400 Invalid CreateSession request.
Metadata
Metadata
Assignees
Labels
api: spannerIssues related to the Spanner API.Issues related to the Spanner API.backendexternalThis issue is blocked on a bug with the actual product.This issue is blocked on a bug with the actual product.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-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.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.