Commit 07f7503
authored
fix(api-core): prevent overwriting explicit empty strings for optional request_id (#17798)
### Description
This PR addresses code review feedback regarding how
`is_proto3_optional=True` fields are treated:
- **`requests.py`**: Changed the check `if not getattr(...)` to `if
getattr(...) is None` for proto-plus messages and other objects when
`is_proto3_optional=True`. This prevents overwriting an explicitly set
empty string (`""`) with a generated UUID.
- **`test_requests.py`**: Added parameterized test cases for
`is_proto3_optional=True` with explicit empty string values `""` to
verify they are preserved and not overwritten.1 parent 8f55f89 commit 07f7503
2 files changed
Lines changed: 5 additions & 1 deletion
File tree
- packages/google-api-core
- google/api_core/gapic_v1
- tests/unit/gapic
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| |||
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| 68 | + | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
| |||
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
| 78 | + | |
76 | 79 | | |
77 | 80 | | |
78 | 81 | | |
| |||
81 | 84 | | |
82 | 85 | | |
83 | 86 | | |
| 87 | + | |
84 | 88 | | |
85 | 89 | | |
86 | 90 | | |
| |||
0 commit comments