Skip to content

(DI)REGAPIC generated Promise types in long running operations appear to be incorrect #548

@feywind

Description

@feywind

I noticed this when I was working on something else entirely, and I'm not sure I want to try to fix it as part of this (may be a breaking change even if it's wrong).

The template looks like this:

{%- if method.isDiregapicLRO %}
      Promise<[
        LROperation<{{ util.toInterface(method.outputInterface) }}, null>,
        {{ util.toInterface(method.outputInterface) }}|undefined, {}|undefined
{%- else %}
      Promise<[
        {{ util.toInterface(method.outputInterface) }},
        {{ util.toInterface(method.inputInterface) }}|undefined, {}|undefined
{%- endif %}
      ]>|void {

It seems to me like the intended difference between these two blocks is LROperation<> wrapping, versus not, but the first one has method.outputInterface twice. The generated code looks like this:

  delete(
      request?: protos.google.cloud.compute.v1.IDeleteAddressRequest,
      optionsOrCallback?: CallOptions|Callback<
          protos.google.cloud.compute.v1.IOperation,
          protos.google.cloud.compute.v1.IDeleteAddressRequest|null|undefined,
          {}|null|undefined>,
      callback?: Callback<
          protos.google.cloud.compute.v1.IOperation,
          protos.google.cloud.compute.v1.IDeleteAddressRequest|null|undefined,
          {}|null|undefined>):
      Promise<[
        LROperation<protos.google.cloud.compute.v1.IOperation, null>,
        protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined
      ]>|void {

The Promise at the bottom shows IOperation twice, but the callbacks show IOperation and IDeleteAddressRequest (this is in compute cjs). This leads me to believe, given the parallels in the type thruple, that there's an issue here. Probably the second one in the Promise part should also be IDeleteAddressRequest.

Environment details

  • Programming language: Generator templates
  • OS: Linux
  • Language runtime version: Node 18.12.0
  • Package version: main

Steps to reproduce

  • It's just part of the repo templates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Moderately-important priority. Fix may not be included in next release.size: sPull request size is small.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions