Skip to content

[log] Add debug logging to config_core.go#4074

Merged
lpcox merged 2 commits intomainfrom
log/config-core-debug-logging-e98f5da26177fbfc
Apr 18, 2026
Merged

[log] Add debug logging to config_core.go#4074
lpcox merged 2 commits intomainfrom
log/config-core-debug-logging-e98f5da26177fbfc

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Adds 5 meaningful debug logging calls to internal/config/config_core.go using the existing logConfig logger ("config:config").

Changes

applyGatewayDefaults — logs resolved defaults after all zero-value fields are filled in:

Applied gateway defaults: port=3000, startupTimeout=30, toolTimeout=60, keepaliveInterval=1500

LoadFromFile — adds intermediate progress logs between the existing entry/exit log calls:

  1. Before unknown-field check: Checking N undecoded TOML keys against allowed fields
  2. Before stdio containerization validation: Validating stdio server containerization requirements for N servers
  3. Before auth validation loop: Validating auth configuration for N servers
  4. When opentelemetry section is present: opentelemetry section found: merging into tracing config, endpoint=...

Why

LoadFromFile already logs at entry and exit but its many intermediate validation steps were invisible under debug logging. These additions make it easy to pinpoint which validation step fails or how far initialization progressed when troubleshooting startup issues with DEBUG=config:*.

Validation

  • go build ./... — passes ✅
  • go vet ./... — passes ✅
  • go test ./internal/... — all packages pass; only TestFetchAndFixSchema_NetworkError fails, which is a pre-existing network-dependent test failure unrelated to these changes ✅

Warning

⚠️ Firewall blocked 1 domain

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

  • invalidhostthatdoesnotexist12345.com

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

network:
  allowed:
    - defaults
    - "invalidhostthatdoesnotexist12345.com"

See Network Configuration for more information.

Generated by Go Logger Enhancement · ● 8.4M ·

…ults

- Log undecoded TOML key count before unknown-field validation
- Log server count before stdio containerization validation
- Log server count before auth configuration validation
- Log when opentelemetry config is merged into tracing
- Log applied gateway defaults (port, timeouts, keepalive interval)

These log calls use the existing logConfig logger and are activated
via DEBUG=config:* or DEBUG=* to help diagnose configuration loading
issues at startup.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions bot added automation enhancement New feature or request labels Apr 18, 2026
@lpcox lpcox marked this pull request as ready for review April 18, 2026 15:58
Copilot AI review requested due to automatic review settings April 18, 2026 15:58
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 additional debug logging in the config loader to make TOML parsing/defaulting/validation progress visible under DEBUG=config:*.

Changes:

  • Log resolved gateway defaults after default application.
  • Add progress logs around unknown-key checking, stdio containerization validation, and auth validation in LoadFromFile.
  • Log when gateway.opentelemetry is present and merged into tracing.
Show a summary per file
File Description
internal/config/config_core.go Adds debug logs for gateway default resolution and intermediate LoadFromFile validation/merge steps.

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: 3

Comment thread internal/config/config_core.go Outdated
}

// Validate TOML stdio servers use Docker for containerization (Spec Section 3.2.1)
logConfig.Printf("Validating stdio server containerization requirements for %d servers", len(cfg.Servers))
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

This debug log uses len(cfg.Servers), but the validation is specifically about stdio server containerization. Using the total server count can be confusing (HTTP servers are included in the number); consider logging the number of stdio servers being checked (or adjust the wording to avoid implying all servers are stdio).

Suggested change
logConfig.Printf("Validating stdio server containerization requirements for %d servers", len(cfg.Servers))
stdioServerCount := 0
for _, serverCfg := range cfg.Servers {
if serverCfg.Type == "stdio" {
stdioServerCount++
}
}
logConfig.Printf("Validating stdio server containerization requirements for %d stdio servers", stdioServerCount)

Copilot uses AI. Check for mistakes.
Comment thread internal/config/config_core.go Outdated
// Merge opentelemetry key into tracing when present (spec §4.1.3.6).
// opentelemetry takes precedence over the legacy tracing key.
if cfg.Gateway.Opentelemetry != nil {
logConfig.Printf("opentelemetry section found: merging into tracing config, endpoint=%s", cfg.Gateway.Opentelemetry.Endpoint)
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

Logging cfg.Gateway.Opentelemetry.Endpoint verbatim can leak sensitive information if the endpoint URL ever contains credentials (userinfo), tokens in query params, or internal hostnames, and it will also be written to the debug log file. Consider logging only whether the endpoint is set, or logging a sanitized form (e.g., scheme/host only, with userinfo/query redacted).

Copilot uses AI. Check for mistakes.
Comment thread internal/config/config_core.go Outdated
if cfg.KeepaliveInterval == 0 {
cfg.KeepaliveInterval = DefaultKeepaliveInterval
}
logConfig.Printf("Applied gateway defaults: port=%d, startupTimeout=%d, toolTimeout=%d, keepaliveInterval=%d",
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

The log message "Applied gateway defaults" is emitted unconditionally, even when no defaults were actually applied (e.g., all fields were already set). This can be misleading during debugging; consider either (a) tracking whether any field was defaulted and only logging when changes occurred, or (b) rewording the message to reflect that this is the resolved gateway config after defaulting.

Suggested change
logConfig.Printf("Applied gateway defaults: port=%d, startupTimeout=%d, toolTimeout=%d, keepaliveInterval=%d",
logConfig.Printf("Resolved gateway config after defaulting: port=%d, startupTimeout=%d, toolTimeout=%d, keepaliveInterval=%d",

Copilot uses AI. Check for mistakes.
@lpcox
Copy link
Copy Markdown
Collaborator

lpcox commented Apr 18, 2026

@copilot address the review feedback #4074 (review)

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 18, 2026

@copilot address the review feedback #4074 (review)

Addressed in commit f07cbfd.

I implemented the requested review feedback in internal/config/config_core.go:

  • changed the defaults log text to “Resolved gateway config after defaulting...”
  • log now reports the count of stdio servers (not total servers) for containerization validation
  • removed raw endpoint logging and now log only whether an OpenTelemetry endpoint is set (endpoint_set=true|false)

@lpcox lpcox merged commit b543069 into main Apr 18, 2026
14 checks passed
@lpcox lpcox deleted the log/config-core-debug-logging-e98f5da26177fbfc branch April 18, 2026 16:13
Copilot stopped work on behalf of lpcox due to an error April 18, 2026 16:13
Copilot AI requested a review from lpcox April 18, 2026 16:13
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