Skip to content

Commit 3b2a946

Browse files
Add debug logging to proxy/response_transform.go
Add 5 debug log calls to unwrapSingleObject and replaceNodesArray functions in the proxy package, reusing the existing logTransform logger (logger.New("proxy:response_transform")). The new log calls trace: - When a wrapped empty array is restored to top-level shape - When a wrapped array matches the original and is restored - When a search envelope (total_count) is skipped - When a GraphQL response envelope (data field) is skipped - When a single-element filtered array is unwrapped - When replaceNodesArray replaces a nodes/edges key with DIFC-filtered items These calls are gated by the DEBUG=proxy:* env var and help developers trace how the GitHub API proxy transforms responses during DIFC enforcement. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 20bcf27 commit 3b2a946

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

internal/proxy/response_transform.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@ func unwrapSingleObject(originalData interface{}, filteredData interface{}) inte
5959
if wrapped, ok := arr[0].([]interface{}); ok &&
6060
len(wrapped) == len(originalArray) {
6161
if len(wrapped) == 0 {
62+
logTransform.Print("unwrapSingleObject: restoring wrapped empty array to original top-level shape")
6263
return wrapped
6364
}
6465
if reflect.DeepEqual(wrapped, originalArray) {
66+
logTransform.Printf("unwrapSingleObject: restoring wrapped array to original top-level shape, len=%d", len(wrapped))
6567
return wrapped
6668
}
6769
}
@@ -75,14 +77,17 @@ func unwrapSingleObject(originalData interface{}, filteredData interface{}) inte
7577
}
7678
// Don't unwrap search envelopes (handled by rewrapSearchResponse)
7779
if _, hasTotalCount := original["total_count"]; hasTotalCount {
80+
logTransform.Print("unwrapSingleObject: skipping search envelope (has total_count field)")
7881
return filteredData
7982
}
8083
// Don't unwrap GraphQL responses (handled separately)
8184
if _, hasData := original["data"]; hasData {
85+
logTransform.Print("unwrapSingleObject: skipping GraphQL response envelope (has data field)")
8286
return filteredData
8387
}
8488
// If filtered result is a single-element array, unwrap to match original shape
8589
if arr, ok := filteredData.([]interface{}); ok && len(arr) == 1 {
90+
logTransform.Print("unwrapSingleObject: unwrapping single-element filtered array to match original object shape")
8691
return arr[0]
8792
}
8893
return filteredData
@@ -143,6 +148,7 @@ func replaceNodesArray(v interface{}, items []interface{}) bool {
143148
}
144149
for _, key := range []string{"nodes", "edges"} {
145150
if _, ok := obj[key]; ok {
151+
logTransform.Printf("replaceNodesArray: replacing %q array with %d accessible item(s)", key, len(items))
146152
obj[key] = items
147153
if _, ok := obj["totalCount"]; ok {
148154
obj["totalCount"] = float64(len(items))

0 commit comments

Comments
 (0)