From c443df01ba97229b30065a2a3f405cb124b4df1a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 3 Apr 2026 05:03:59 +0000 Subject: [PATCH] Add debug logging to internal/difc/resource.go Add logger var and 5 targeted debug log calls to help troubleshoot DIFC label aggregation for collection filtering: - CollectionLabeledData.Overall(): log item count before union - CollectionLabeledData.Overall(): log when collection is empty - FilteredCollectionLabeledData.Overall(): log accessible vs filtered counts - FilteredCollectionLabeledData.Overall(): log when no accessible items - FilteredCollectionLabeledData.ToResult(): log returned item count and filter reason Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- internal/difc/resource.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/difc/resource.go b/internal/difc/resource.go index fb04f13c..062baa1f 100644 --- a/internal/difc/resource.go +++ b/internal/difc/resource.go @@ -1,5 +1,9 @@ package difc +import "github.com/github/gh-aw-mcpg/internal/logger" + +var logResource = logger.New("difc:resource") + // Resource represents an external system with label requirements (deprecated - use LabeledResource) type Resource struct { Description string @@ -104,9 +108,11 @@ type LabeledItem struct { func (c *CollectionLabeledData) Overall() *LabeledResource { // Aggregate labels from all items - most restrictive if len(c.Items) == 0 { + logResource.Print("CollectionLabeledData.Overall: empty collection, returning empty labels") return NewLabeledResource("empty collection") } + logResource.Printf("CollectionLabeledData.Overall: aggregating labels from %d items", len(c.Items)) overall := NewLabeledResource("collection") for _, item := range c.Items { if item.Labels != nil { @@ -147,9 +153,11 @@ type FilteredCollectionLabeledData struct { func (f *FilteredCollectionLabeledData) Overall() *LabeledResource { // Only aggregate labels from accessible items if len(f.Accessible) == 0 { + logResource.Print("FilteredCollectionLabeledData.Overall: no accessible items, returning empty labels") return NewLabeledResource("empty filtered collection") } + logResource.Printf("FilteredCollectionLabeledData.Overall: aggregating labels from %d accessible items (%d filtered)", len(f.Accessible), len(f.Filtered)) overall := NewLabeledResource("filtered collection") for _, item := range f.Accessible { if item.Labels != nil { @@ -163,6 +171,7 @@ func (f *FilteredCollectionLabeledData) Overall() *LabeledResource { func (f *FilteredCollectionLabeledData) ToResult() (interface{}, error) { // Return only accessible items + logResource.Printf("FilteredCollectionLabeledData.ToResult: returning %d accessible items (filter_reason=%s)", len(f.Accessible), f.FilterReason) result := make([]interface{}, 0, len(f.Accessible)) for _, item := range f.Accessible { result = append(result, item.Data)