FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

chore: librarian onboard pull request: 20260407T145439Z by daniel-sanche · Pull Request #16574 · googleapis/google-cloud-python · GitHub

chore: librarian onboard pull request: 20260407T145439Z - #16574

Merged
daniel-sanche merged 1 commit into
mainfrom
librarian-20260407T145439Z
Apr 8, 2026
Merged

chore: librarian onboard pull request: 20260407T145439Z#16574
daniel-sanche merged 1 commit into
mainfrom
librarian-20260407T145439Z

Conversation

Copy link
Copy Markdown
Contributor

PR created by the Librarian CLI to onboard a new Cloud Client Library.

BEGIN_COMMIT

feat: onboard a new library

PiperOrigin-RevId: 895558469
Library-IDs: google-cloud-appoptimize

END_COMMIT

Librarian Version: v0.8.3
Language Image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:234b9d1f2ddb057ed7ac6a38db0bf8163d839c65c6cf88ade52530cddebce59e

daniel-sanche requested review from a team as code owners April 7, 2026 21:56

snippet-bot Bot commented Apr 7, 2026

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 10 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Code Review

This pull request introduces the google-cloud-appoptimize library, a new Python client for the App Optimize API (v1beta). The changes encompass the full suite of generated client code, including sync and async interfaces, gRPC and REST transports, and associated samples and tests. Feedback highlights critical bugs in the REST transport's debug logging and example interceptor code. Suggestions for improvement include optimizing query parameter processing using MessageToDict and ensuring deterministic output by programmatically sorting dictionary keys in path parsing and query parameter generation.

): # pragma: NO COVER
try:
response_payload = app_optimize.Report.to_json(response)
except:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The logging code incorrectly attempts to call to_json on the requests.Response object (response) instead of the parsed proto message (resp). This will cause an error during logging when DEBUG level is enabled.

Suggested change
except:
response_payload = app_optimize.Report.to_json(resp)

Comment on lines +1164 to +1166
response
)
except:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The logging code incorrectly attempts to call to_json on the requests.Response object (response) instead of the parsed proto message (resp). This will cause an error during logging when DEBUG level is enabled.

                    response_payload = app_optimize.ListReportsResponse.to_json(
                        resp
                    )

): # pragma: NO COVER
try:
response_payload = app_optimize.ReadReportResponse.to_json(response)
except:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The logging code incorrectly attempts to call to_json on the requests.Response object (response) instead of the parsed proto message (resp). This will cause an error during logging when DEBUG level is enabled.

Suggested change
except:
response_payload = app_optimize.ReadReportResponse.to_json(resp)

Comment on lines +138 to +143
json_format.MessageToJson(
transcoded_request["query_params"],
use_integers_for_enums=True,
)
)
query_params.update(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Using json_format.MessageToDict is more efficient than serializing to a JSON string and then parsing it back into a dictionary. This improvement can be applied to all similar occurrences in this file.

Suggested change
json_format.MessageToJson(
transcoded_request["query_params"],
use_integers_for_enums=True,
)
)
query_params.update(
query_params = json_format.MessageToDict(
transcoded_request["query_params"],
use_integers_for_enums=True,
)


query_params["$alt"] = "json;enum-encoding=int"
return query_params

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

To ensure dictionary keys remain sorted without manual effort, programmatically sort the dictionary before returning it instead of relying on manual ordering in the code. This ensures deterministic behavior for the generated query parameters. This improvement can be applied to all _get_query_params_json methods in this file.

Suggested change
return dict(sorted(query_params.items()))
References
  1. To ensure dictionary keys remain sorted without manual effort, programmatically sort the dictionary before returning it (e.g., using dict(sorted(metadata.items()))) instead of relying on manual ordering in the code.

class MyCustomAppOptimizeInterceptor(AppOptimizeRestInterceptor):
def pre_create_report(self, request, metadata):
logging.log(f"Received request: {request}")
return request, metadata

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The example interceptor uses logging.log without specifying a log level, which will raise a TypeError. It should use a specific level method like logging.info or provide the level as the first argument. This applies to all logging calls in the example.

Suggested change
return request, metadata
logging.info(f"Received request: {request}")

path,
)
return m.groupdict() if m else {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

To ensure dictionary keys remain sorted without manual effort, programmatically sort the dictionary before returning it instead of relying on manual ordering in the code. This applies to all path parsing methods in this class.

Suggested change
return dict(sorted(m.groupdict().items())) if m else {}
References
  1. To ensure dictionary keys remain sorted without manual effort, programmatically sort the dictionary before returning it (e.g., using dict(sorted(metadata.items()))) instead of relying on manual ordering in the code.

chalmerlowe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

daniel-sanche merged commit 8e92bae into main Apr 8, 2026
31 checks passed
daniel-sanche deleted the librarian-20260407T145439Z branch April 8, 2026 16:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL