Skip to content

compute: AI zones are returned when listing zones #13734

@jameshartig

Description

@jameshartig

Client

Compute

Environment

go version go1.25.6 linux/amd64

Code and Dependencies

package main

import (
	"context"
	"fmt"
	"os"

	compute "cloud.google.com/go/compute/apiv1"
	computepb "cloud.google.com/go/compute/apiv1/computepb"
	"google.golang.org/api/iterator"
)

func main() {
	projectID := os.Args[1]
	ctx := context.Background()

	// Create the client
	c, err := compute.NewZonesRESTClient(ctx)
	if err != nil {
		panic(err)
	}
	defer c.Close()

	// List zones
	req := &computepb.ListZonesRequest{
		Project: projectID,
	}

	it := c.List(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			panic(err)
		}
		fmt.Println(resp.GetName())
	}
}
go.mod
module test

go 1.25.6

require (
	cloud.google.com/go/compute v1.54.0
	google.golang.org/api v0.262.0
)

require (
	cloud.google.com/go/auth v0.18.1 // indirect
	cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
	cloud.google.com/go/compute/metadata v0.9.0 // indirect
	github.com/cespare/xxhash/v2 v2.3.0 // indirect
	github.com/felixge/httpsnoop v1.0.4 // indirect
	github.com/go-logr/logr v1.4.3 // indirect
	github.com/go-logr/stdr v1.2.2 // indirect
	github.com/google/s2a-go v0.1.9 // indirect
	github.com/googleapis/enterprise-certificate-proxy v0.3.11 // indirect
	github.com/googleapis/gax-go/v2 v2.16.0 // indirect
	go.opentelemetry.io/auto/sdk v1.2.1 // indirect
	go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 // indirect
	go.opentelemetry.io/otel v1.39.0 // indirect
	go.opentelemetry.io/otel/metric v1.39.0 // indirect
	go.opentelemetry.io/otel/trace v1.39.0 // indirect
	golang.org/x/crypto v0.47.0 // indirect
	golang.org/x/net v0.49.0 // indirect
	golang.org/x/oauth2 v0.34.0 // indirect
	golang.org/x/sys v0.40.0 // indirect
	golang.org/x/text v0.33.0 // indirect
	google.golang.org/genproto v0.0.0-20251202230838-ff82c1b0f217 // indirect
	google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect
	google.golang.org/genproto/googleapis/rpc v0.0.0-20260120174246-409b4a993575 // indirect
	google.golang.org/grpc v1.78.0 // indirect
	google.golang.org/protobuf v1.36.11 // indirect
)

Expected behavior

I don't expect AI zones to be returned.

Actual behavior

AI zones are returned.

Screenshots

...
us-south1-a
us-south1-ai1b
us-south1-b
us-south1-c
...

Additional context

Documentation about AI Zones

The above says:

You must enable the --extraLocationTypes flag when using the locations.list API to ensure AI zones appear only to those who intend to use them.

The documentation for that new field says:

By default, omitting this field means only the generic Cloud locations will be returned in the response. The supported values are: "CLOUD_AI_ZONE"

This API should have similar default-opt-out functionality.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: computeIssues related to the Compute Engine API.triage meI really want to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions