chore: update googleapis and regenerate#17138
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates several Google Cloud client libraries, adding new features and methods for Google Apps Chat, Compute Engine, Kubernetes Engine, Gemini Data Analytics, and Cloud Support. Notable changes include new message notification options, capacity advice functionality, and enhanced GKE cluster configurations. Feedback focuses on correcting errors in the REST transport layer where the wrong object was passed to JSON serialization methods. Additionally, the reviewer recommended replacing broad or bare exception handlers with more specific ones that include proper logging to improve debuggability and prevent silent failures.
| response_payload = compute.CapacityAdviceResponse.to_json(response) | ||
| except: |
There was a problem hiding this comment.
There are two issues here: 1. The to_json method is being called with the HTTP response object (a requests.Response instance) instead of the parsed message object resp. 2. Avoid broad except Exception: blocks that silently return None. Instead, log the exception (e.g., using logger.warning) to aid in debugging and prevent masking underlying issues.
| response_payload = compute.CapacityAdviceResponse.to_json(response) | |
| except: | |
| response_payload = compute.CapacityAdviceResponse.to_json(resp) | |
| except Exception as e: | |
| logger.warning(f"Error occurred: {e}") |
References
- Avoid broad except Exception: blocks that silently return None. Instead, log the exception (e.g., using logger.warning) to aid in debugging and prevent masking underlying issues.
| response_payload = compute.CapacityHistoryResponse.to_json(response) | ||
| except: |
There was a problem hiding this comment.
The to_json method is called with the wrong object (response instead of resp). Additionally, avoid broad except Exception: blocks that silently return None. Instead, log the exception (e.g., using logger.warning) to aid in debugging and prevent masking underlying issues.
| response_payload = compute.CapacityHistoryResponse.to_json(response) | |
| except: | |
| response_payload = compute.CapacityHistoryResponse.to_json(resp) | |
| except Exception as e: | |
| logger.warning(f"Error occurred: {e}") |
References
- Avoid broad except Exception: blocks that silently return None. Instead, log the exception (e.g., using logger.warning) to aid in debugging and prevent masking underlying issues.
| response_payload = compute.Policy.to_json(response) | ||
| except: |
There was a problem hiding this comment.
The to_json method is called with the wrong object (response instead of resp). Additionally, avoid broad except Exception: blocks that silently return None. Instead, log the exception (e.g., using logger.warning) to aid in debugging and prevent masking underlying issues.
| response_payload = compute.Policy.to_json(response) | |
| except: | |
| response_payload = compute.Policy.to_json(resp) | |
| except Exception as e: | |
| logger.warning(f"Error occurred: {e}") |
References
- Avoid broad except Exception: blocks that silently return None. Instead, log the exception (e.g., using logger.warning) to aid in debugging and prevent masking underlying issues.
| response_payload = attachment.Attachment.to_json(response) | ||
| except: |
There was a problem hiding this comment.
The to_json method is called with the wrong object (response instead of resp). Additionally, avoid broad except Exception: blocks that silently return None. Instead, log the exception (e.g., using logger.warning) to aid in debugging and prevent masking underlying issues.
| response_payload = attachment.Attachment.to_json(response) | |
| except: | |
| response_payload = attachment.Attachment.to_json(resp) | |
| except Exception as e: | |
| logger.warning(f"Error occurred: {e}") |
References
- Avoid broad except Exception: blocks that silently return None. Instead, log the exception (e.g., using logger.warning) to aid in debugging and prevent masking underlying issues.
| method = transcoded_request["method"] | ||
| try: | ||
| request_payload = type(request).to_json(request) | ||
| except: |
There was a problem hiding this comment.
Avoid using bare except: blocks. Catching Exception is preferred to avoid intercepting system-level signals. Additionally, log the exception (e.g., using logger.warning) to aid in debugging and prevent masking underlying issues, as per the repository's guidelines.
| except: | |
| except Exception as e: | |
| logger.warning(f"Error occurred: {e}") |
References
- Avoid broad except Exception: blocks that silently return None. Instead, log the exception (e.g., using logger.warning) to aid in debugging and prevent masking underlying issues.
Update googleapis to the latest commit and regenerate all client libraries.