Skip to content

[log] proxy/handler: add debug logging to forwardAndReadBody and writeEmptyResponse#7066

Merged
lpcox merged 2 commits into
mainfrom
log/proxy-handler-forward-logging-10a036d9a33a4dd0
Jun 6, 2026
Merged

[log] proxy/handler: add debug logging to forwardAndReadBody and writeEmptyResponse#7066
lpcox merged 2 commits into
mainfrom
log/proxy-handler-forward-logging-10a036d9a33a4dd0

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented Jun 5, 2026

Adds 5 logHandler calls to two previously-unlogged helper functions in the DIFC proxy pipeline.

Changes

forwardAndReadBody (4 new log calls):

  • Entry: logs method and path so every upstream request is traceable
  • Upstream error: logs method, path, and error when forwardToGitHub fails (previously only a 502 was emitted with no diagnostics)
  • Body-read error: logs method, path, status, and error if io.ReadAll fails mid-stream
  • Success: logs method, path, response status, and body length

writeEmptyResponse (1 new log call):

  • Logs which empty JSON shape ([], {"data":null}, or {}) was selected and the upstream status code — useful when DIFC policy filters items and callers receive an empty response

Why these functions?

forwardAndReadBody is called from every code path in handleWithDIFC. Before this change, a GitHub API failure appeared in logs only as a generic 502 with no indication of which method/path was involved or whether the failure was during the HTTP call or while reading the body. writeEmptyResponse is similarly opaque: there was no log entry explaining why a DIFC-filtered response took a particular empty shape.

Validation

  • go build -o awmg .
  • go vet ./...
  • go test ./... ✅ (all packages pass)
  • Reuses existing logHandler = logger.New("proxy:handler") — no new logger declaration needed
  • No side effects in log arguments

Warning

Firewall blocked 1 domain

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:

network:
  allowed:
    - defaults
    - "index.crates.io"

See Network Configuration for more information.

Generated by Go Logger Enhancement · sonnet46 14M ·

…Response

Add 5 meaningful logHandler calls to two previously-unlogged helper functions:
- forwardAndReadBody: entry (method+path), upstream error, body-read error, success (status+bodyLen)
- writeEmptyResponse: chosen shape and status code

These functions are called from every DIFC proxy request path. Without these
logs it is impossible to distinguish a GitHub API failure from a response-read
failure, or to understand why an empty shape was chosen when policy filters items.

Reuses the existing logHandler variable declared in this file.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added automation enhancement New feature or request labels Jun 5, 2026
@lpcox lpcox marked this pull request as ready for review June 6, 2026 15:43
Copilot AI review requested due to automatic review settings June 6, 2026 15:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds debug-level trace logging to previously opaque helper functions in the DIFC proxy handler, improving diagnosability of upstream request failures and empty-response shaping without changing proxy behavior.

Changes:

  • Add debug logs to forwardAndReadBody for entry, upstream-call failure, body-read failure, and success summary.
  • Add debug log to writeEmptyResponse to record the selected empty JSON shape and upstream status.
Show a summary per file
File Description
internal/proxy/handler.go Adds debug logging in forwardAndReadBody and writeEmptyResponse to improve request/response traceability in the proxy pipeline.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment thread internal/proxy/handler.go Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@lpcox lpcox merged commit 07b6793 into main Jun 6, 2026
16 checks passed
@lpcox lpcox deleted the log/proxy-handler-forward-logging-10a036d9a33a4dd0 branch June 6, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants