Skip to content

Commit f3ed8f1

Browse files
authored
[log] Add debug logging to proxy/response_transform.go (#7739)
Add 5 debug log calls to `unwrapSingleObject` and `replaceNodesArray` in `internal/proxy/response_transform.go`, reusing the existing `logTransform` logger (`logger.New("proxy:response_transform")`). ## Changes **`unwrapSingleObject`** – traces the 5 distinct code paths this function takes when deciding how to reshape a GitHub API response after DIFC filtering: | Path | New log call | |---|---| | Wrapped empty array restored to top-level | `logTransform.Print("... restoring wrapped empty array ...")` | | Wrapped array matches original, restored | `logTransform.Printf("... restoring wrapped array ..., len=%d")` | | Search envelope skipped (`total_count` present) | `logTransform.Print("... skipping search envelope ...")` | | GraphQL response envelope skipped (`data` present) | `logTransform.Print("... skipping GraphQL response envelope ...")` | | Single-element filtered array unwrapped | `logTransform.Print("... unwrapping single-element filtered array ...")` | **`replaceNodesArray`** – logs which key (`nodes` or `edges`) was replaced and how many DIFC-accessible items remain: ``` logTransform.Printf("replaceNodesArray: replacing %q array with %d accessible item(s)", key, len(items)) ``` ## Validation - `go build ./...` ✅ - `go test ./...` ✅ (all 25 packages) - `go vet ./...` ✅ - No import cycles — `proxy` is a higher-level package that safely imports `logger` - No side effects in log arguments — all values are already-computed locals ## Activation ```bash DEBUG=proxy:* ./awmg --config config.toml ``` > [!WARNING] > <details> > <summary>Firewall blocked 1 domain</summary> > > The following domain was blocked by the firewall during workflow execution: > > - `index.crates.io` >> To allow these domains, add them to the `network.allowed` list in your workflow frontmatter: > > ```yaml > network: > allowed: > - defaults > - "index.crates.io" > ``` > > See [Network Configuration](https://github.github.com/gh-aw/reference/network/) for more information. > > </details> > Generated by [Go Logger Enhancement](https://github.com/github/gh-aw-mcpg/actions/runs/27796617195) · 2.3K AIC · ⊞ 34.9K · [◷](https://github.com/search?q=repo%3Agithub%2Fgh-aw-mcpg+%22gh-aw-workflow-id%3A+go-logger%22&type=pullrequests) <!-- gh-aw-agentic-workflow: Go Logger Enhancement, engine: copilot, version: 1.0.60, model: claude-sonnet-4.6, id: 27796617195, workflow_id: go-logger, run: https://github.com/github/gh-aw-mcpg/actions/runs/27796617195 --> <!-- gh-aw-workflow-id: go-logger --> <!-- gh-aw-workflow-call-id: github/gh-aw-mcpg/go-logger -->
2 parents 20bcf27 + 3b2a946 commit f3ed8f1

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)