Skip to content

nodejs: Disable snippet_metadata file generation #5787

@quirogas

Description

@quirogas

To completely remove the generation and maintenance of snippet_metadata_*.json files across the Node.js client libraries, as these files are no longer actively use (seee go/snippet-gen-design).

Proposed Changes

1. TypeScript Generator (gapic-generator-typescript)

The generator is the source of these files. We should stop it from emitting them entirely.

  • Modify templater.ts:
    • Remove the if (outputFilename.match(/snippet_metadata/)) block in processOneTemplate(). This block currently bypasses standard template rendering to manually construct the JSON metadata.
    • Remove the createSnippetIndexMetadata() and createSnippetMetadata() helper functions.
    • Remove the countRegionTagLines() and findRegionTag() helpers if they are not used elsewhere.
  • Cleanup Templates:
    • Delete templates/esm/typescript_samples/samples/generated/$version/snippet_metadata_$apiNamingProtoPackage.json.njk.
    • Delete templates/cjs/typescript_samples/samples/generated/$version/snippet_metadata_$apiNamingProtoPackage.json.njk.

2. Librarian (googleapis/librarian)

Librarian currently contains post-processing logic to update the hardcoded 0.1.0 version in these files.

  • Modify internal/librarian/nodejs/generate.go:
    • Remove the call to updateSnippetMetadataVersion().
    • Delete the updateSnippetMetadataVersion() function and its related types (snippetMetadata, clientLibrary).
  • Cleanup v1small Workarounds:
    • The v1small skip in updateSnippetMetadataVersion() can be removed once the function is deleted.

3. Cleanup PR (Monorepo-wide)

Once generation is disabled, we should perform one final sweep of the monorepo to delete all existing snippet_metadata_*.json files to avoid having orphaned files.

Implementation Path

  1. Submit PR to google-cloud-node (or gapic-generator-typescript repo) to disable generation.
  2. Submit PR to librarian to remove the version-updating post-processor.
  3. Execute a monorepo-wide deletion PR (similar to Task 5.3) for all modern UNDERSCORE metadata files.

Benefits

  • Reduced Diff Noise: Eliminates a large source of churn (version bumps and line shifts) in every generation PR.
  • Faster Generation: Skips the expensive template scanning and region tag counting logic in the generator.
  • Cleaner Pipeline: Removes complex post-processing logic from Librarian.
  • Reduces Toil:: addresses Nodejs: 0.1.0 Snippet Metadata Version Leakage synthtool#2173

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions