Skip to content

run: Invalid default endpoint for service #12389

Closed
@murarustefaan

Description

@murarustefaan

Client

cloud.google.com/go/run/apiv2.NewLocationsClient(...)

Environment

e.g. Alpine Docker on GKE
MacOS development environment (redundant, it's sdk related)

e.g. $ go version
1.24.3

Code and Dependencies

package run

import (
	v2 "cloud.google.com/go/run/apiv2"
	locationpb "google.golang.org/genproto/googleapis/cloud/location"
)

func fetchLocations(ctx context.Context, meta schema.ClientMeta, _ *schema.Resource, res chan<- any) error {
	c := meta.(*client.Client)
	gcpClient, err := v2.NewLocationsClient(ctx, c.ClientOptions...)
	if err != nil {
		return err
	}
	it := gcpClient.ListLocations(ctx, &locationpb.ListLocationsRequest{Name: "projects/" + c.ProjectId}, c.CallOptions...)
	return client.Iterate(ctx, it, c, res)
}

Expected behavior

The locations fetched by the SDK call above to be the regions where the Cloud Run API is supported for the given project.

Actual behavior

The API call above returns a full list of locations, including regional, zonal as well as the continent.

Additional context

This happens due to the fact that the DefaultEndpoint for the locations client is cloud.googleapis.com:443, rather than run.googleapis.com:443. Setting the option.WithEndpoint("run.googleapis.com:443") when instantiating the v2.NewLocationsClient(ctx, c.ClientOptions...) above solves the issue.

However, due to the fact that

  1. the CLI returns the regions supported by Cloud Run and
  2. Cloud Run is also a regional service
    i believe that by default the endpoint should always be run.googleapis.com:443.

Thanks in advance for any feedback you might have!

Metadata

Metadata

Assignees

Labels

api: runIssues related to the Cloud Run API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.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