Skip to content

v6: Fetching GatewayListItems always return an empty result #4192

@senuphtyz

Description

@senuphtyz

Confirm this is a Go library issue and not an underlying Cloudflare API issue

  • This is an issue with the Go library

Describe the bug

Trying to fetch items from a ZeroTrust Gateway List always returns in an empty results et.
Using mitmproxy shows that the API request is properly done and returns data.

After changing the function signatures in gatewaylistitem.go result are available.

37c37
< func (r *GatewayListItemService) List(ctx context.Context, listID string, query GatewayListItemListParams, opts ...option.RequestOption) (res *pagination.SinglePage[[]GatewayItem], err error) {
---
> func (r *GatewayListItemService) List(ctx context.Context, listID string, query GatewayListItemListParams, opts ...option.RequestOption) (res *pagination.SinglePage[GatewayItem], err error) {
63c63
< func (r *GatewayListItemService) ListAutoPaging(ctx context.Context, listID string, query GatewayListItemListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[[]GatewayItem] {
---
> func (r *GatewayListItemService) ListAutoPaging(ctx context.Context, listID string, query GatewayListItemListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[GatewayItem] {

To Reproduce

  1. Create a ZeroTrust Gateway List
  2. Add an entry to that List
  3. Try to fetch items from the List

Code snippets

package main

import (
	"context"
	"fmt"

	"github.com/cloudflare/cloudflare-go/v6"
	"github.com/cloudflare/cloudflare-go/v6/option"
	"github.com/cloudflare/cloudflare-go/v6/zero_trust"
)

func main() {
	accountId := "[ACCOUNT ID]"
	apiToken := "[TOKEN HERE]"
	listId := "[LIST ID]"

	client := cloudflare.NewClient(
		option.WithAPIToken(apiToken),
	)

	ctx := context.Background()

	page := client.ZeroTrust.Gateway.Lists.Items.ListAutoPaging(
		ctx,
		listId,
		zero_trust.GatewayListItemListParams{
			AccountID: cloudflare.F(accountId),
		},
	)

	for page.Next() {
		l := page.Current()
		fmt.Println(l)
	}

	if page.Err() != nil {
		panic(page.Err())
	}
}

OS

Ubuntu 24.04

Go version

Go 1.24.7

Library version

github.com/cloudflare/cloudflare-go/v6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions