Skip to content

NewListPager always returns 0 results for TaskRunsClient #23897

@ToxicGLaDOS

Description

@ToxicGLaDOS

Bug Report

I never get any results from NewListPager when trying to list task runs via TaskRunsClient. I've tried using versions 1.0.0-1.3.0-beta.2 and it doesn't seem to make a difference. The example doesn't seem to work either (after replacing "<subscription-id>", "myResourceGroup", and "myRegistry"). Here's a minimal example that shows the problem (alternatively you could replace the values and run the link above).

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry"
)

var (
    subscriptionID = "<subscription-id>"
    resourceGroup = "<resource-group>"
    registryName = "<registry>"
)

func main() {
    cred, err := azidentity.NewDefaultAzureCredential(nil)
    if err != nil {
        log.Fatal("Couldn't create credential\n")
    }

    containerRegistryClientFactory, err := armcontainerregistry.NewClientFactory(subscriptionID, cred, nil)
	if err != nil {
		log.Fatal(err)
	}

    taskRunsClient := containerRegistryClientFactory.NewTaskRunsClient()
    taskRunsPager := taskRunsClient.NewListPager(resourceGroup, registryName, nil)

    for taskRunsPager.More() {
        fmt.Println("More")
        page, err := taskRunsPager.NextPage(context.Background())
        if err != nil {
            log.Fatal(err)
        }

        j, err := page.MarshalJSON()
        fmt.Println(string(j))

        for _, taskRun := range page.Value {
            fmt.Println("TaskRun")
            fmt.Printf("%s: %s\n", *taskRun.Name, *taskRun.Properties.RunResult.Name)
        }

    }
}

This yields

More
{"value":[]}

even though this registry definitely has task runs in it's history. This is confirmed by using the azure-cli: az acr task list-runs -r <registry> --subscription <subscription-id> If there were an error I'd expect to hit one of the error conditions.

We can tell that it's at least connecting to the registry because changing the the registry name to a name that doesn't exist yields an error.

module path:
sdk/resourcemanager/containerregistry/armcontainerregistry

go version:
go version go1.22.7 linux/amd64

Metadata

Metadata

Assignees

No one assigned

    Labels

    Container RegistryMgmtThis issue is related to a management-plane library.Service AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions