Skip to content

fix(nodejs): remove all common proto configuration#6277

Draft
jskeet wants to merge 1 commit into
googleapis:mainfrom
jskeet:no-common-protos
Draft

fix(nodejs): remove all common proto configuration#6277
jskeet wants to merge 1 commit into
googleapis:mainfrom
jskeet:no-common-protos

Conversation

@jskeet

@jskeet jskeet commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

The common resources proto is unconditionally passed into the gapic
generator so that the generator knows about the common resource
patterns and can generate helper functions, but is then
unconditionally deleted from the protos directory. The only reason we
currently have those files in google-cloud-node is because they were
included at one point and never cleaned up.

After removal, the code is simpler and migration won't end up creating
unnecessary files.

Trying to reproduce the Bazel behavior to match which proto files are
included and which are copied would be very complicated; this approach
is simpler (albeit less "clean" feeling).

Fixes #6024

@jskeet jskeet requested a review from quirogas June 3, 2026 10:13
@jskeet jskeet requested a review from a team as a code owner June 3, 2026 10:13

@gemini-code-assist 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.

Code Review

This pull request removes the omit_common_resources configuration option and its associated logic across the codebase, including documentation, configuration structures, generation logic, migration tools, and tests. Feedback on the changes suggests simplifying a redundant conditional check and removing a redundant Path field when instantiating the NodejsAPI configuration in the migration tool.

Comment thread tool/cmd/migrate/nodejs.go
@jskeet

jskeet commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

I've run "migrate and regenerate everything" with this PR, and:

@jskeet jskeet added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jun 3, 2026
@quirogas

quirogas commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

For posterity, we discussed that removing common_protos will impact some generated code in certain packages, such as secretmanager; we must first examine the removed code to determine if its absence is acceptable before deciding whether to proceed with the change.


Reproduction steps

migrate .

add librarian.js to the glogal keep list

default:
  keep:
    - package.json
    - samples/package.json
    - README.md
    - CHANGELOG.md
    - .readme-partials.yaml
    - librarian.js. # <---- add this
librarian generate google-cloud-secretmanager
git diff packages/google-cloud-secretmanager/src/v1/secret_manager_service_client.ts
diff --git a/packages/google-cloud-secretmanager/src/v1/secret_manager_service_client.ts b/packages/google-cloud-secretmanager/src/v1/secret_manager_service_client.ts
index 7083ad06d1..b3d0387869 100644
--- a/packages/google-cloud-secretmanager/src/v1/secret_manager_service_client.ts
+++ b/packages/google-cloud-secretmanager/src/v1/secret_manager_service_client.ts
@@ -215,9 +215,6 @@ export class SecretManagerServiceClient {
     // identifiers to uniquely identify resources within the API.
     // Create useful helper objects for these.
     this.pathTemplates = {
-      projectPathTemplate: new this._gaxModule.PathTemplate(
-        'projects/{project}',
-      ),
       projectLocationSecretSecretVersionPathTemplate:
         new this._gaxModule.PathTemplate(
           'projects/{project}/locations/{location}/secrets/{secret}/versions/{secret_version}',
@@ -2901,29 +2898,6 @@ export class SecretManagerServiceClient {
   // -- Path templates --
   // --------------------
 
-  /**
-   * Return a fully-qualified project resource name string.
-   *
-   * @param {string} project
-   * @returns {string} Resource name string.
-   */
-  projectPath(project: string) {
-    return this.pathTemplates.projectPathTemplate.render({
-      project: project,
-    });
-  }
-
-  /**
-   * Parse the project from Project resource.
-   *
-   * @param {string} projectName
-   *   A fully-qualified path representing Project resource.
-   * @returns {string} A string representing the project.
-   */
-  matchProjectFromProjectName(projectName: string) {
-    return this.pathTemplates.projectPathTemplate.match(projectName).project;
-  }
-
   /**
    * Return a fully-qualified projectLocationSecretSecretVersion resource name string.
    *
```](url)

@jskeet

jskeet commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

Marked as "do not merge" because this changes the generated code - we no longer generate code for project resources, for example. I'll look into it in more detail.

The common resources proto is unconditionally passed into the gapic
generator so that the generator knows about the common resource
patterns and can generate helper functions, but is then
unconditionally deleted from the protos directory. The only reason we
currently have those files in google-cloud-node is because they were
included at one point and never cleaned up.

After removal, the code is simpler and migration won't end up creating
unnecessary files.

Trying to reproduce the Bazel behavior to match which proto files are
included and which are copied would be very complicated; this approach
is simpler (albeit less "clean" feeling).

Fixes googleapis#6024
@jskeet jskeet force-pushed the no-common-protos branch from dd3f9f3 to a5e8f01 Compare June 5, 2026 09:53
@jskeet jskeet removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jun 5, 2026
@jskeet jskeet requested a review from JoeWang1127 June 5, 2026 10:19
@jskeet

jskeet commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

This is now changed to always pass in google/cloud/common_resources.proto to the generator, and always remove it from the protos directory afterwards.

@jskeet

jskeet commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

(I've regenerated everything, and the diffs we were seeing are no longer present.)

@jskeet jskeet added do not merge Indicates a pull request not ready for merge, due to either quality or timing. and removed do not merge Indicates a pull request not ready for merge, due to either quality or timing. labels Jun 5, 2026
@jskeet

jskeet commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

This does create a diff for advisory-notifications (and potentially some other APIs), but I think it's okay - it basically adds path templates that aren't strictly necessary. Unfortunately advisory-notifications has a large set of other diffs, so it's tricky to see what's just due to this change, but I think we're okay.

@quirogas quirogas 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.

I think we should still keep the ability to omit common protos for now to keep the diff small. Perhaps we could rename the flag to reflect that it doesn't have any resources and keep it?

@jskeet jskeet marked this pull request as draft June 5, 2026 14:37
@jskeet

jskeet commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

Converting back to a draft for now while we're discussing it.

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.

nodejs: be selective about passing in google/cloud/common_resources.proto

3 participants