Skip to content

Conversation

@brittanycho
Copy link
Contributor

Upgrades functions::list command to utilize Cloud Run API:

Upgrades by adding new function (listServices) to runV2.ts and defining trigger within endpointFromService function. Then listServices and endpointFromService are newly utilized in functions-list.ts so that this command now uses cloud run api

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @brittanycho, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the functions:list command to leverage the Cloud Run API for listing functions. This change enables the command to accurately retrieve and display Cloud Run-based functions, providing more detailed trigger information and improving the overall user experience for managing serverless deployments.

Highlights

  • Cloud Run API Integration: The functions:list command has been upgraded to utilize the Cloud Run API for retrieving and displaying functions, moving away from the previous Cloud Functions backend.
  • New listServices Function: A new asynchronous function, listServices, has been added to src/gcp/runv2.ts to fetch all Cloud Run services for a given project, including robust pagination handling.
  • Enhanced Trigger Detection: The endpointFromService function in src/gcp/runv2.ts has been updated to accurately determine and define trigger types (HTTP or event-based) for functions based on service annotations.
  • Permission Update: The functions:list command now requires the run.services.list permission, reflecting its reliance on the Cloud Run API.
  • Output Table Refinement: The functions:list command's output table has been modified to replace the 'Version' column with 'Platform', providing more relevant information for Cloud Run services.
  • Comprehensive Testing for listServices: New unit tests have been added in src/gcp/runv2.spec.ts to ensure the listServices function correctly fetches services, handles pagination, and manages API errors.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

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

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 the functions:list command to use the Cloud Run API, which is a significant improvement. The implementation looks solid, with good test coverage for the new listServices function. I have a couple of suggestions to improve type safety and error logging.

@brittanycho brittanycho changed the title Fr/cloud run fns list Upgrades functions::list command to utilize Cloud Run API Oct 31, 2025
brittanycho and others added 3 commits October 31, 2025 22:39
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@brittanycho brittanycho requested a review from taeold November 3, 2025 22:17
@brittanycho
Copy link
Contributor Author

/gemini review

Copy link
Contributor

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

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 successfully upgrades the functions::list command to use the Cloud Run API, which is a great improvement for supporting Cloud Run-based functions. I've found a critical issue where GCFv2 functions could be duplicated in the list, and I've provided a fix. I also have a minor suggestion to improve performance in the new listServices function. Overall, the changes are well-structured and the tests for the new functionality are thorough.

brittanycho and others added 5 commits November 5, 2025 23:06
@github-project-automation github-project-automation bot moved this to Changes Requested [PR] in [Cloud] Extensions + Functions Nov 7, 2025
…d relevant tests for backend.ts, add tests to runv2.spec.ts, call listService with label for v2 functions
@brittanycho
Copy link
Contributor Author

/gemini review

Copy link
Contributor

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

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 is a great step forward in upgrading the functions::list command to utilize the Cloud Run API, ensuring all function types are listed. The changes are well-organized across the command, backend, and API client layers, and the new tests are a welcome addition. I have a couple of suggestions to enhance code clarity and robustness, mainly around simplifying endpoint de-duplication and improving the label filtering logic. Overall, this is a solid contribution.

brittanycho and others added 2 commits November 10, 2025 17:21
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@brittanycho brittanycho requested a review from taeold November 11, 2025 04:33
@brittanycho
Copy link
Contributor Author

I see the tests are failing but seem unrelated to my current changes? will hopefully pass when re-syncing tomorrow

@brittanycho
Copy link
Contributor Author

/gemini review

Copy link
Contributor

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

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 upgrades the functions::list command to use the Cloud Run API, which is a great enhancement for supporting Cloud Run-based functions. The changes are well-structured, including updates to the command itself, the backend logic for fetching functions, and the necessary API client code for Cloud Run. The error handling in functions-list.ts is a good addition for robustness.

I've found a couple of issues: one is a broken test being added, and the other is a minor maintainability concern that could lead to silent errors in the future. Please see my detailed comments.

: {
eventTrigger: {
eventType: service.annotations?.[TRIGGER_TYPE_ANNOTATION] || "unknown",
retry: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

why is retry always false here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

iiuc, I don't think the Cloud Run Service object stores info on retry policies so I don't think we'd be able to know the actual retry setting for a trigger? I didn't see any related fields in https://cloud.google.com/run/docs/reference/rest/v2/projects.locations.services#resource:-service

"functions",
`Failed to list Cloud Run services: ${err.message}. Ensure you have the Cloud Run Admin API enabled and the necessary permissions.`,
);
unreachableRegions.run = ["unknown"]; // Indicate that Run services could not be listed
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a bit surprising. does the Run API not return list of unreacheable regions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I couldn't find anything in the services.list Service object or in other Cloud Run documentation through a google search but I could definitely be missing something - I will follow-up and ask in the Cloud Run Space

Copy link
Contributor Author

@brittanycho brittanycho Nov 12, 2025

Choose a reason for hiding this comment

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

Update on above here: https://chat.google.com/room/AAAA8PjxsIE/mgFct9F0k9I/mgFct9F0k9I?cls=10

Discussed further offline with Daniel and decided to move forward with this PR without unreachable regions and will add it back in later when it is fully deployed by cloud run

@brittanycho
Copy link
Contributor Author

/gemini review

Copy link
Contributor

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

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 is a solid architectural improvement, upgrading the functions::list command to use the Cloud Run API for v2 functions. The changes make the command more robust, especially with the improved error handling that prevents crashes when listing functions fails. The code is generally clean and well-tested. My review focuses on further enhancing the robustness of error handling in a couple of places to prevent potential issues with unexpected error formats, and on improving the safety of error reporting to avoid leaking sensitive information.

brittanycho and others added 2 commits November 13, 2025 14:56
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@brittanycho brittanycho requested a review from taeold November 13, 2025 23:52
endpoints = backend.allEndpoints(existing);
} catch (err: any) {
logger.debug(`Failed to list functions:`, err);
logger.warn(err.message);
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm should we warn or err?

Copy link
Contributor

Choose a reason for hiding this comment

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

also, if we are not doing anything useful with the returned error, removing the try/cactch block and letting the CLI just throw the error is an option


describe("existing backend", () => {
let listAllFunctions: sinon.SinonStub;
let listAllFunctionsV2: sinon.SinonStub;
Copy link
Contributor

Choose a reason for hiding this comment

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

can we remove this stub as well?

beforeEach(() => {
listAllFunctions = sinon.stub(gcf, "listAllFunctions").rejects("Unexpected call");
listAllFunctionsV2 = sinon.stub(gcfV2, "listAllFunctions").rejects("Unexpected v2 call");
listServices = sinon.stub(runv2, "listServices").resolves([]);
Copy link
Contributor

Choose a reason for hiding this comment

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

should call .reject() like other stubs

Comment on lines -166 to -169
listAllFunctionsV2.onFirstCall().resolves({
functions: [],
unreachable: [],
});
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of deleting this, can we have it return empty run services (goes w/ changing runStub to reject in the before() setup

Comment on lines +554 to +555
logger.debug(err.message);
unreachableRegions.run = ["unknown"]; // Indicate that Run services could not be listed
Copy link
Contributor

Choose a reason for hiding this comment

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

q: why do we ignore errors? e.g. what if 403 is thrown?

}
context.unreachableRegions.run = ["region"];

await expect(backend.checkAvailability(context, want)).to.eventually.be.rejectedWith(
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm why does this test pass? i thought we don't call out to v2 api endpoint anymore

);
const neededUnreachableV2 = context.unreachableRegions?.gcfV2.filter((region) =>
const neededUnreachableV2 = context.unreachableRegions?.run.filter((region) =>
gcfV2Regions.has(region),
Copy link
Contributor

Choose a reason for hiding this comment

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

should we rename this var or no?

Comment on lines +1 to +3
- [Added] support for new google-genai plugin during `init genkit` (#8957)
- Updated to v2.17.1 of the Data Connect emulator, which fixes an admin SDK bug for operation without argument #9449 (#9454).
- Upgraded functions::list command to use cloud run api for v2 functions (#9425)
Copy link
Contributor

Choose a reason for hiding this comment

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

remove and add our own changelist bullet?

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