Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 951bc78

Browse files
committed
fix: resolve issue where ValueError is not raised if both request and flattened param are set
1 parent d9d40cc commit 951bc78

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

gapic/templates/%namespace/%name_%version/%sub/services/%service/_client_macros.j2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@
9090
{% if method.flattened_fields %}
9191
# - Quick check: If we got a request object, we should *not* have
9292
# gotten any keyword arguments that map to the request.
93-
has_flattened_params = any([{{ method.flattened_fields.values()|join(", ", attribute="name") }}])
93+
flattened_params = [{{ method.flattened_fields.values()|join(", ", attribute="name") }}]
94+
has_flattened_params = len([param for param in flattened_params if param is not None]) > 0
9495
if request is not None and has_flattened_params:
9596
raise ValueError('If the `request` argument is set, then none of '
9697
'the individual field arguments should be set.')

gapic/templates/%namespace/%name_%version/%sub/services/%service/async_client.py.j2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ class {{ service.async_client_name }}:
317317
{% if method.flattened_fields %}
318318
# - Quick check: If we got a request object, we should *not* have
319319
# gotten any keyword arguments that map to the request.
320-
has_flattened_params = any([{{ method.flattened_fields.values()|join(", ", attribute="name") }}])
320+
flattened_params = [{{ method.flattened_fields.values()|join(", ", attribute="name") }}]
321+
has_flattened_params = len([param for param in flattened_params if param is not None]) > 0
321322
if request is not None and has_flattened_params:
322323
raise ValueError("If the `request` argument is set, then none of "
323324
"the individual field arguments should be set.")

0 commit comments

Comments
 (0)