Skip to content

Commit 313a403

Browse files
Add debug logging to config_core.go LoadFromFile and applyGatewayDefaults
- 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 <[email protected]>
1 parent ac8733a commit 313a403

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

internal/config/config_core.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ func applyGatewayDefaults(cfg *GatewayConfig) {
260260
if cfg.KeepaliveInterval == 0 {
261261
cfg.KeepaliveInterval = DefaultKeepaliveInterval
262262
}
263+
logConfig.Printf("Applied gateway defaults: port=%d, startupTimeout=%d, toolTimeout=%d, keepaliveInterval=%d",
264+
cfg.Port, cfg.StartupTimeout, cfg.ToolTimeout, cfg.KeepaliveInterval)
263265
}
264266

265267
// EnsureGatewayDefaults guarantees that cfg.Gateway is non-nil and that all
@@ -350,6 +352,7 @@ func LoadFromFile(path string) (*Config, error) {
350352
// Note: map[string]interface{} fields (guard_policies, guards.*.config) are
351353
// intentionally flexible and their nested keys are exempt from this check.
352354
undecoded := md.Undecoded()
355+
logConfig.Printf("Checking %d undecoded TOML keys against allowed fields", len(undecoded))
353356
var unknownKeys []toml.Key
354357
for _, key := range undecoded {
355358
if !isDynamicTOMLPath(key) {
@@ -370,13 +373,15 @@ func LoadFromFile(path string) (*Config, error) {
370373
}
371374

372375
// Validate TOML stdio servers use Docker for containerization (Spec Section 3.2.1)
376+
logConfig.Printf("Validating stdio server containerization requirements for %d servers", len(cfg.Servers))
373377
if err := validateTOMLStdioContainerization(cfg.Servers); err != nil {
374378
return nil, err
375379
}
376380

377381
// Validate auth configs (e.g. fail-fast for missing OIDC env vars).
378382
// This ensures parity with the JSON stdin path which calls validateServerAuth
379383
// via convertStdinServerConfig → validateServerConfigWithCustomSchemas.
384+
logConfig.Printf("Validating auth configuration for %d servers", len(cfg.Servers))
380385
for name, serverCfg := range cfg.Servers {
381386
jsonPath := fmt.Sprintf("servers.%s", name)
382387
if err := validateServerAuth(serverCfg.Auth, serverCfg.Type, name, jsonPath); err != nil {
@@ -397,6 +402,7 @@ func LoadFromFile(path string) (*Config, error) {
397402
// Merge opentelemetry key into tracing when present (spec §4.1.3.6).
398403
// opentelemetry takes precedence over the legacy tracing key.
399404
if cfg.Gateway.Opentelemetry != nil {
405+
logConfig.Printf("opentelemetry section found: merging into tracing config, endpoint=%s", cfg.Gateway.Opentelemetry.Endpoint)
400406
cfg.Gateway.Tracing = cfg.Gateway.Opentelemetry
401407
cfg.Gateway.Opentelemetry = nil
402408
// Expand ${VAR} expressions in tracing fields before validation.

0 commit comments

Comments
 (0)