Skip to content

chore(appengine): upgrade Google Cloud dependencies to ^2.0 - #2346

Merged
bshaffer merged 2 commits into
mainfrom
appengine/upgrade-v2
Nov 6, 2026
Merged

bshaffer merged 2 commits into
mainfrom
appengine/upgrade-v2

Conversation

@bshaffer

@bshaffer bshaffer commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Upgrade App Engine and Error Reporting samples to the latest google/cloud-* releases:

  • Update google/cloud-datastore, google/cloud-logging, and google/cloud-storage to ^2.0, and google/cloud-error-reporting to ^0.28.0
  • Migrate appengine/standard/grpc/speech.php to google/cloud-speech v2
  • Update appengine/standard/tasks, appengine/flexible/datastore, and Error Reporting tests for v2 compatibility

@bshaffer
bshaffer requested review from a team as code owners November 6, 2026 17:28
@product-auto-label product-auto-label Bot added api: appengine Issues related to the App Engine Admin API API. samples Issues that are directly related to samples. labels Nov 6, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates several Google Cloud client libraries to their latest major versions (such as upgrading google/cloud-datastore, google/cloud-logging, and google/cloud-storage to ^2.0) across various App Engine samples. It adapts the code to the new library APIs, including migrating to request objects for RPC calls (e.g., ListGroupStatsRequest, ListEventsRequest, and CreateTaskRequest) and upgrading the Speech API usage from V1 to V2. The review feedback correctly identifies an opportunity to improve code readability in DeployTest.php and VerifyReportedErrorTrait.php by avoiding the reuse of the $response variable name in nested loops.

Comment on lines +116 to 128
$request = (new ListGroupStatsRequest())
->setProjectName($projectName)
->setTimeRange($timeRange);
$response = $errorStats->listGroupStats($request);
foreach ($response->iterateAllElements() as $groupStat) {
$response = $errorStats->listEvents($projectName, $groupStat->getGroup()->getGroupId(), [
'timeRange' => $timeRange,
]);
$eventsRequest = (new ListEventsRequest())
->setProjectName($projectName)
->setGroupId($groupStat->getGroup()->getGroupId())
->setTimeRange($timeRange);
$response = $errorStats->listEvents($eventsRequest);
foreach ($response->iterateAllElements() as $event) {
$messages[] = $event->getMessage();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Reusing the $response variable name for both the outer listGroupStats response and the inner listEvents response is confusing and can lead to readability or maintenance issues. It is cleaner and more idiomatic to use distinct, descriptive variable names like $groupStatsResponse and $eventsResponse.

            $request = (new ListGroupStatsRequest())
                ->setProjectName($projectName)
                ->setTimeRange($timeRange);
            $groupStatsResponse = $errorStats->listGroupStats($request);
            foreach ($groupStatsResponse->iterateAllElements() as $groupStat) {
                $eventsRequest = (new ListEventsRequest())
                    ->setProjectName($projectName)
                    ->setGroupId($groupStat->getGroup()->getGroupId())
                    ->setTimeRange($timeRange);
                $eventsResponse = $errorStats->listEvents($eventsRequest);
                foreach ($eventsResponse->iterateAllElements() as $event) {
                    $messages[] = $event->getMessage();
                }

Comment on lines +61 to 75
$request = (new ListGroupStatsRequest())
->setProjectName($projectName)
->setTimeRange($timeRange)
->setPageSize(100);
$response = $errorStats->listGroupStats($request);
foreach ($response->iterateAllElements() as $groupStat) {
$response = $errorStats->listEvents($projectName, $groupStat->getGroup()->getGroupId(), [
'timeRange' => $timeRange,
'pageSize' => 100,
]);
$eventsRequest = (new ListEventsRequest())
->setProjectName($projectName)
->setGroupId($groupStat->getGroup()->getGroupId())
->setTimeRange($timeRange)
->setPageSize(100);
$response = $errorStats->listEvents($eventsRequest);
foreach ($response->iterateAllElements() as $event) {
$messages[] = $event->getMessage();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Reusing the $response variable name for both the outer listGroupStats response and the inner listEvents response is confusing and can lead to readability or maintenance issues. It is cleaner and more idiomatic to use distinct, descriptive variable names like $groupStatsResponse and $eventsResponse.

            $request = (new ListGroupStatsRequest())
                ->setProjectName($projectName)
                ->setTimeRange($timeRange)
                ->setPageSize(100);
            $groupStatsResponse = $errorStats->listGroupStats($request);
            foreach ($groupStatsResponse->iterateAllElements() as $groupStat) {
                $eventsRequest = (new ListEventsRequest())
                    ->setProjectName($projectName)
                    ->setGroupId($groupStat->getGroup()->getGroupId())
                    ->setTimeRange($timeRange)
                    ->setPageSize(100);
                $eventsResponse = $errorStats->listEvents($eventsRequest);
                foreach ($eventsResponse->iterateAllElements() as $event) {
                    $messages[] = $event->getMessage();
                }

@bshaffer
bshaffer merged commit c6706a4 into main Nov 6, 2026
12 checks passed
@bshaffer
bshaffer deleted the appengine/upgrade-v2 branch November 6, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: appengine Issues related to the App Engine Admin API API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant