Skip to content

feat(generator): select resumable upload methods - #9284

Draft
feywind wants to merge 2 commits into
googleapis:mainfrom
feywind:resumable/generator-params
Draft

feat(generator): select resumable upload methods#9284
feywind wants to merge 2 commits into
googleapis:mainfrom
feywind:resumable/generator-params

Conversation

@feywind

@feywind feywind commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Adds a resumable_upload_methods generator parameter: a semicolon-separated list of Service.Method pairs that should be treated as resumable upload methods, e.g. ResumableUploadService.CreateResumableUpload.

Selected methods are augmented with a resumable upload descriptor, removed from the simple methods list, and exposed on the service as resumableUploads. The parameter is plumbed through the CLI, the typescript_gapic_library bazel rule and the naming options.

This PR is plumbing only — the templates that consume service.resumableUploads land separately, so generated output is unchanged. The pubsub api dump baselines are refreshed for the new resumableUploads field.

Verification

  • npm run compile
  • npm test — 190 passing (generator unit and baseline tests)

The resumable upload client templates build on this and will be sent as a follow-up.

Related to: #9283

Adds the `resumable_upload_methods` generator parameter: a
semicolon-separated list of `Service.Method` pairs. Selected methods are
augmented with a resumable upload descriptor, removed from the simple
methods list, and exposed on the service as `resumableUploads`, which the
templates use to generate the resumable upload clients.

Plumbs the parameter through the CLI, the bazel rule and the naming
options, and refreshes the pubsub api dump baselines for the new
`resumableUploads` field.

@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 introduces support for a new generator parameter, resumable_upload_methods, allowing users to specify service methods that should use the resumable upload protocol. This includes updates to Bazel rules, CLI parsing, and schema generation, along with corresponding unit tests. Feedback is provided to defensively check the type of the resumable-upload-methods parameter before calling .split() to prevent a potential runtime TypeError if it is parsed as a boolean.

Comment on lines +256 to +263
private readResumableUploadMethods() {
if (this.paramMap['resumable-upload-methods']) {
this.resumableUploadMethods = this.paramMap['resumable-upload-methods']
.split(';')
.map(name => name.trim())
.filter(name => name.length > 0);
}
}

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.

medium

If resumable-upload-methods is passed as a boolean flag (e.g., without an explicit value), this.paramMap['resumable-upload-methods'] might be parsed as a boolean true. Calling .split(';') on a boolean will throw a runtime TypeError. We should defensively check that the value is a string before splitting. Additionally, ensure that this parameter parsing method has corresponding unit tests to verify that values are correctly parsed and normalized.

  private readResumableUploadMethods() {
    const value = this.paramMap['resumable-upload-methods'];
    if (typeof value === 'string') {
      this.resumableUploadMethods = value
        .split(';')
        .map(name => name.trim())
        .filter(name => name.length > 0);
    }
  }
References
  1. Ensure that parameter parsing methods (such as readX methods) and parameter mapping (getParamMap) in the generator have corresponding unit tests to verify that values are correctly parsed and normalized (e.g., to kebab-case).

The monorepo linter's prettier disagrees with two spots touched by this
change:

- the resumableUploadMethods cast in gapic-generator-typescript.ts
- the streaming union in schema/proto.ts, which is pre-existing
  formatting from main that the newer prettier prints on one line

Pure formatting; no behavior change.
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.

1 participant