Skip to content

Commit 14c195c

Browse files
Merge branch 'main' into retry_generators
2 parents 9ba7676 + 0acda8c commit 14c195c

File tree

8 files changed

+102
-37
lines changed

8 files changed

+102
-37
lines changed

.github/.OwlBot.lock.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
# limitations under the License.
1414
docker:
1515
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
16-
digest: sha256:2e247c7bf5154df7f98cce087a20ca7605e236340c7d6d1a14447e5c06791bd6
16+
digest: sha256:240b5bcc2bafd450912d2da2be15e62bc6de2cf839823ae4bf94d4f392b451dc
17+
# created: 2023-06-03T21:25:37.968717478Z

.kokoro/requirements.txt

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -113,28 +113,26 @@ commonmark==0.9.1 \
113113
--hash=sha256:452f9dc859be7f06631ddcb328b6919c67984aca654e5fefb3914d54691aed60 \
114114
--hash=sha256:da2f38c92590f83de410ba1a3cbceafbc74fee9def35f9251ba9a971d6d66fd9
115115
# via rich
116-
cryptography==39.0.1 \
117-
--hash=sha256:0f8da300b5c8af9f98111ffd512910bc792b4c77392a9523624680f7956a99d4 \
118-
--hash=sha256:35f7c7d015d474f4011e859e93e789c87d21f6f4880ebdc29896a60403328f1f \
119-
--hash=sha256:5aa67414fcdfa22cf052e640cb5ddc461924a045cacf325cd164e65312d99502 \
120-
--hash=sha256:5d2d8b87a490bfcd407ed9d49093793d0f75198a35e6eb1a923ce1ee86c62b41 \
121-
--hash=sha256:6687ef6d0a6497e2b58e7c5b852b53f62142cfa7cd1555795758934da363a965 \
122-
--hash=sha256:6f8ba7f0328b79f08bdacc3e4e66fb4d7aab0c3584e0bd41328dce5262e26b2e \
123-
--hash=sha256:706843b48f9a3f9b9911979761c91541e3d90db1ca905fd63fee540a217698bc \
124-
--hash=sha256:807ce09d4434881ca3a7594733669bd834f5b2c6d5c7e36f8c00f691887042ad \
125-
--hash=sha256:83e17b26de248c33f3acffb922748151d71827d6021d98c70e6c1a25ddd78505 \
126-
--hash=sha256:96f1157a7c08b5b189b16b47bc9db2332269d6680a196341bf30046330d15388 \
127-
--hash=sha256:aec5a6c9864be7df2240c382740fcf3b96928c46604eaa7f3091f58b878c0bb6 \
128-
--hash=sha256:b0afd054cd42f3d213bf82c629efb1ee5f22eba35bf0eec88ea9ea7304f511a2 \
129-
--hash=sha256:ced4e447ae29ca194449a3f1ce132ded8fcab06971ef5f618605aacaa612beac \
130-
--hash=sha256:d1f6198ee6d9148405e49887803907fe8962a23e6c6f83ea7d98f1c0de375695 \
131-
--hash=sha256:e124352fd3db36a9d4a21c1aa27fd5d051e621845cb87fb851c08f4f75ce8be6 \
132-
--hash=sha256:e422abdec8b5fa8462aa016786680720d78bdce7a30c652b7fadf83a4ba35336 \
133-
--hash=sha256:ef8b72fa70b348724ff1218267e7f7375b8de4e8194d1636ee60510aae104cd0 \
134-
--hash=sha256:f0c64d1bd842ca2633e74a1a28033d139368ad959872533b1bab8c80e8240a0c \
135-
--hash=sha256:f24077a3b5298a5a06a8e0536e3ea9ec60e4c7ac486755e5fb6e6ea9b3500106 \
136-
--hash=sha256:fdd188c8a6ef8769f148f88f859884507b954cc64db6b52f66ef199bb9ad660a \
137-
--hash=sha256:fe913f20024eb2cb2f323e42a64bdf2911bb9738a15dba7d3cce48151034e3a8
116+
cryptography==41.0.0 \
117+
--hash=sha256:0ddaee209d1cf1f180f1efa338a68c4621154de0afaef92b89486f5f96047c55 \
118+
--hash=sha256:14754bcdae909d66ff24b7b5f166d69340ccc6cb15731670435efd5719294895 \
119+
--hash=sha256:344c6de9f8bda3c425b3a41b319522ba3208551b70c2ae00099c205f0d9fd3be \
120+
--hash=sha256:34d405ea69a8b34566ba3dfb0521379b210ea5d560fafedf9f800a9a94a41928 \
121+
--hash=sha256:3680248309d340fda9611498a5319b0193a8dbdb73586a1acf8109d06f25b92d \
122+
--hash=sha256:3c5ef25d060c80d6d9f7f9892e1d41bb1c79b78ce74805b8cb4aa373cb7d5ec8 \
123+
--hash=sha256:4ab14d567f7bbe7f1cdff1c53d5324ed4d3fc8bd17c481b395db224fb405c237 \
124+
--hash=sha256:5c1f7293c31ebc72163a9a0df246f890d65f66b4a40d9ec80081969ba8c78cc9 \
125+
--hash=sha256:6b71f64beeea341c9b4f963b48ee3b62d62d57ba93eb120e1196b31dc1025e78 \
126+
--hash=sha256:7d92f0248d38faa411d17f4107fc0bce0c42cae0b0ba5415505df72d751bf62d \
127+
--hash=sha256:8362565b3835ceacf4dc8f3b56471a2289cf51ac80946f9087e66dc283a810e0 \
128+
--hash=sha256:84a165379cb9d411d58ed739e4af3396e544eac190805a54ba2e0322feb55c46 \
129+
--hash=sha256:88ff107f211ea696455ea8d911389f6d2b276aabf3231bf72c8853d22db755c5 \
130+
--hash=sha256:9f65e842cb02550fac96536edb1d17f24c0a338fd84eaf582be25926e993dde4 \
131+
--hash=sha256:a4fc68d1c5b951cfb72dfd54702afdbbf0fb7acdc9b7dc4301bbf2225a27714d \
132+
--hash=sha256:b7f2f5c525a642cecad24ee8670443ba27ac1fab81bba4cc24c7b6b41f2d0c75 \
133+
--hash=sha256:b846d59a8d5a9ba87e2c3d757ca019fa576793e8758174d3868aecb88d6fc8eb \
134+
--hash=sha256:bf8fc66012ca857d62f6a347007e166ed59c0bc150cefa49f28376ebe7d992a2 \
135+
--hash=sha256:f5d0bf9b252f30a31664b6f64432b4730bb7038339bd18b1fafe129cfc2be9be
138136
# via
139137
# gcp-releasetool
140138
# secretstorage
@@ -419,9 +417,9 @@ readme-renderer==37.3 \
419417
--hash=sha256:cd653186dfc73055656f090f227f5cb22a046d7f71a841dfa305f55c9a513273 \
420418
--hash=sha256:f67a16caedfa71eef48a31b39708637a6f4664c4394801a7b0d6432d13907343
421419
# via twine
422-
requests==2.28.1 \
423-
--hash=sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983 \
424-
--hash=sha256:8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349
420+
requests==2.31.0 \
421+
--hash=sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f \
422+
--hash=sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1
425423
# via
426424
# gcp-releasetool
427425
# google-api-core

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44

55
[1]: https://pypi.org/project/google-api-core/#history
66

7+
## [2.11.1](https://github.com/googleapis/python-api-core/compare/v2.11.0...v2.11.1) (2023-06-12)
8+
9+
10+
### Bug Fixes
11+
12+
* Add actionable errors for GCE long running operations ([#498](https://github.com/googleapis/python-api-core/issues/498)) ([7dfc3a7](https://github.com/googleapis/python-api-core/commit/7dfc3a7a439243f05238a11b68a31720fde1769e))
13+
* Invalid `dev` version identifiers in `setup.py` ([#505](https://github.com/googleapis/python-api-core/issues/505)) ([8844edb](https://github.com/googleapis/python-api-core/commit/8844edb1e802040810918a12bc9ff89104da38d4))
14+
715
## [2.11.0](https://github.com/googleapis/python-api-core/compare/v2.10.2...v2.11.0) (2022-11-10)
816

917

google/api_core/exceptions.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,21 @@ def __init__(self, message, errors=(), details=(), response=None, error_info=Non
142142
self._error_info = error_info
143143

144144
def __str__(self):
145+
error_msg = "{} {}".format(self.code, self.message)
145146
if self.details:
146-
return "{} {} {}".format(self.code, self.message, self.details)
147+
error_msg = "{} {}".format(error_msg, self.details)
148+
# Note: This else condition can be removed once proposal A from
149+
# b/284179390 is implemented.
147150
else:
148-
return "{} {}".format(self.code, self.message)
151+
if self.errors:
152+
errors = [
153+
f"{error.code}: {error.message}"
154+
for error in self.errors
155+
if hasattr(error, "code") and hasattr(error, "message")
156+
]
157+
if errors:
158+
error_msg = "{} {}".format(error_msg, "\n".join(errors))
159+
return error_msg
149160

150161
@property
151162
def reason(self):

google/api_core/extended_operation.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,16 @@ def _handle_refreshed_operation(self):
158158
return
159159

160160
if self.error_code and self.error_message:
161+
# Note: `errors` can be removed once proposal A from
162+
# b/284179390 is implemented.
163+
errors = []
164+
if hasattr(self, "error") and hasattr(self.error, "errors"):
165+
errors = self.error.errors
161166
exception = exceptions.from_http_status(
162167
status_code=self.error_code,
163168
message=self.error_message,
164169
response=self._extended_operation,
170+
errors=errors,
165171
)
166172
self.set_exception(exception)
167173
elif self.error_code or self.error_message:

google/api_core/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = "2.11.0"
15+
__version__ = "2.11.1"

setup.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@
2929
# 'Development Status :: 5 - Production/Stable'
3030
release_status = "Development Status :: 5 - Production/Stable"
3131
dependencies = [
32-
"googleapis-common-protos >= 1.56.2, < 2.0dev",
33-
"protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5",
34-
"google-auth >= 2.14.1, < 3.0dev",
35-
"requests >= 2.18.0, < 3.0.0dev",
32+
"googleapis-common-protos >= 1.56.2, < 2.0.dev0",
33+
"protobuf>=3.19.5,<5.0.0.dev0,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5",
34+
"google-auth >= 2.14.1, < 3.0.dev0",
35+
"requests >= 2.18.0, < 3.0.0.dev0",
3636
]
3737
extras = {
3838
"grpc": [
3939
"grpcio >= 1.33.2, < 2.0dev",
4040
"grpcio >= 1.49.1, < 2.0dev; python_version>='3.11'",
41-
"grpcio-status >= 1.33.2, < 2.0dev",
42-
"grpcio-status >= 1.49.1, < 2.0dev; python_version>='3.11'",
41+
"grpcio-status >= 1.33.2, < 2.0.dev0",
42+
"grpcio-status >= 1.49.1, < 2.0.dev0; python_version>='3.11'",
4343
],
44-
"grpcgcp": "grpcio-gcp >= 0.2.2, < 1.0dev",
45-
"grpcio-gcp": "grpcio-gcp >= 0.2.2, < 1.0dev",
44+
"grpcgcp": "grpcio-gcp >= 0.2.2, < 1.0.dev0",
45+
"grpcio-gcp": "grpcio-gcp >= 0.2.2, < 1.0.dev0",
4646
}
4747

4848

tests/unit/test_extended_operation.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,23 @@ class StatusCode(enum.Enum):
3333
DONE = 1
3434
PENDING = 2
3535

36+
class LROCustomErrors:
37+
class LROCustomError:
38+
def __init__(self, code: str = "", message: str = ""):
39+
self.code = code
40+
self.message = message
41+
42+
def __init__(self, errors: typing.List[LROCustomError] = []):
43+
self.errors = errors
44+
3645
name: str
3746
status: StatusCode
3847
error_code: typing.Optional[int] = None
3948
error_message: typing.Optional[str] = None
4049
armor_class: typing.Optional[int] = None
50+
# Note: `error` can be removed once proposal A from
51+
# b/284179390 is implemented.
52+
error: typing.Optional[LROCustomErrors] = None
4153

4254
# Note: in generated clients, this property must be generated for each
4355
# extended operation message type.
@@ -170,6 +182,35 @@ def test_error():
170182
with pytest.raises(exceptions.BadRequest):
171183
ex_op.result()
172184

185+
# Test GCE custom LRO Error. See b/284179390
186+
# Note: This test case can be removed once proposal A from
187+
# b/284179390 is implemented.
188+
_EXCEPTION_CODE = "INCOMPATIBLE_BACKEND_SERVICES"
189+
_EXCEPTION_MESSAGE = "Validation failed for instance group"
190+
responses = [
191+
CustomOperation(
192+
name=TEST_OPERATION_NAME,
193+
status=CustomOperation.StatusCode.DONE,
194+
error_code=400,
195+
error_message="Bad request",
196+
error=CustomOperation.LROCustomErrors(
197+
errors=[
198+
CustomOperation.LROCustomErrors.LROCustomError(
199+
code=_EXCEPTION_CODE, message=_EXCEPTION_MESSAGE
200+
)
201+
]
202+
),
203+
),
204+
]
205+
206+
ex_op, _, _ = make_extended_operation(responses)
207+
208+
# Defaults to CallError when grpc is not installed
209+
with pytest.raises(
210+
exceptions.BadRequest, match=f"{_EXCEPTION_CODE}: {_EXCEPTION_MESSAGE}"
211+
):
212+
ex_op.result()
213+
173214
# Inconsistent result
174215
responses = [
175216
CustomOperation(

0 commit comments

Comments
 (0)