googleapis / google-cloud-go

Google Cloud Client Libraries for Go.
https://cloud.google.com/go/docs/reference
Apache License 2.0
3.8k stars 1.31k forks source link

grafeas/apiv1: no value is returned from the iterator #3838

Closed ucpr closed 3 years ago

ucpr commented 3 years ago

Client

grafeas/apiv1

Environment

Google Cloud Functions, Macbook Pro (2019)

Go Environment

$ go version
go version go1.13 darwin/amd64

Code

package main

import (
    "context"
    "fmt"
    "log"

    grafeas "cloud.google.com/go/grafeas/apiv1"
    "google.golang.org/api/iterator"
    grafeaspb "google.golang.org/genproto/googleapis/grafeas/v1"
)

func main() {
    ctx := context.Background()
    c, err := grafeas.NewClient(ctx)
    if err != nil {
        log.Println(err)
    }
        projectID := os.Getenv("GCP_PROJECT_ID")

    req := &grafeaspb.ListOccurrencesRequest{
        Parent: fmt.Sprintf("projects/%q", projectID),
    }
    it := c.ListOccurrences(ctx, req)
    for {
        resp, err := it.Next()  // not work
        if err == iterator.Done {
            break
        }
        if err != nil {
            log.Println(err)
        }
        log.Println(resp)
    }
}

Expected behavior

it.Next() does not return a value and the process stops there.

Actual behavior

it.Next() returns a value and the process proceeds.

Additional context

https://github.com/googleapis/google-cloud-go/blob/7b265c31d18abf4998af13e547bdf0fb1ed904b3/grafeas/apiv1/grafeas_client.go#L432

https://github.com/googleapis/gax-go/blob/fbaf9882acf3297573f3a7cb832e54c7d8f40635/v2/invoke.go#L67

I think that the number of retries is not specified and the process is stopped in the retry process.

ucpr commented 3 years ago

Sorry, it doesn't seem to be a library problem.