Skip to content

[log] Add debug logging to TLS helper functions in proxy/tls.go#9285

Merged
lpcox merged 3 commits into
mainfrom
log/proxy-tls-helper-functions-bf098f6fd583e84d
Jul 14, 2026
Merged

[log] Add debug logging to TLS helper functions in proxy/tls.go#9285
lpcox merged 3 commits into
mainfrom
log/proxy-tls-helper-functions-bf098f6fd583e84d

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

Adds logTLS debug logging calls to helper functions in internal/proxy/tls.go that previously had no logging coverage.

Changes

  • GenerateSelfSignedTLS: Added log call after os.MkdirAll to confirm the TLS directory was ensured.
  • randomSerial: Added log call after successful serial number generation, showing the generated value.
  • writePEM: Added log calls at function entry (path, type, size) and on successful write.

These logs appear under DEBUG=proxy:* and are zero-overhead when debug logging is disabled. They help trace certificate generation issues during development and troubleshooting.

Checklist

  • Exactly 1 file modified (internal/proxy/tls.go)
  • No test files modified
  • Logger declaration already existed (var logTLS = logger.New("proxy:tls")), reused
  • Logger naming follows pkg:filename convention
  • No side effects in log arguments
  • Logging messages are meaningful and helpful
  • No duplicate logging with existing logs
  • go build passes
  • go test ./internal/proxy/ passes
  • go vet ./internal/proxy/ passes

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Generated by Go Logger Enhancement · 507.3 AIC · ⊞ 7.6K ·

Add logTLS debug logging calls to randomSerial and writePEM helper
functions, and to the TLS directory creation step in
GenerateSelfSignedTLS. These provide visibility into:
- TLS directory creation path
- Random serial number generation values
- PEM file write operations (path, type, size)
- PEM file write completion

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added automation enhancement New feature or request labels Jul 13, 2026
@lpcox lpcox marked this pull request as ready for review July 14, 2026 16:48
Copilot AI review requested due to automatic review settings July 14, 2026 16:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 tracing to TLS certificate generation and PEM file writes.

Changes:

  • Logs TLS directory and serial generation.
  • Logs PEM write attempts and successful encoding.
Show a summary per file
File Description
internal/proxy/tls.go Adds TLS helper debug logging.

Review details

Tip

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

  • Files reviewed: 1/1 changed files
  • Comments generated: 2
  • Review effort level: Medium

Comment thread internal/proxy/tls.go Outdated
if serial.Sign() == 0 {
serial = new(big.Int).Add(serial, big.NewInt(1))
}
logTLS.Printf("generated random serial number: %s", serial.String())
Comment thread internal/proxy/tls.go
if err := pem.Encode(f, &pem.Block{Type: blockType, Bytes: derBytes}); err != nil {
return err
}
logTLS.Printf("PEM file written successfully: path=%s", path)
@lpcox

lpcox commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

@copilot address review feedback

Copilot AI added 2 commits July 14, 2026 17:42
- Pass *big.Int directly to Printf instead of calling .String() eagerly
- Close file explicitly in writePEM, handle close error, and only log
  success after confirmed close
Log the file close error when pem.Encode fails, rather than silently
discarding it.

Copilot AI commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

@copilot address review feedback

Addressed in the latest commits:

  1. randomSerial (line 193): Removed .String()serial (*big.Int) is now passed directly to Printf, so the string conversion only happens inside the logger when it's actually enabled.

  2. writePEM (line 207): Removed defer f.Close() and replaced with explicit close calls. pem.Encode error path now logs any close error before returning the encode error. The success log only fires after f.Close() succeeds.

Copilot finished work on behalf of lpcox July 14, 2026 17:43
Copilot AI requested a review from lpcox July 14, 2026 17:43
@lpcox lpcox merged commit bffd48b into main Jul 14, 2026
25 checks passed
@lpcox lpcox deleted the log/proxy-tls-helper-functions-bf098f6fd583e84d branch July 14, 2026 18:31
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.

3 participants