Skip to content

[log] cmd/flags_difc: add debug logging for DIFC policy and mode resolution#1856

Merged
lpcox merged 1 commit intomainfrom
log/flags-difc-debug-logging-fa3cd2c4928dd52a
Mar 13, 2026
Merged

[log] cmd/flags_difc: add debug logging for DIFC policy and mode resolution#1856
lpcox merged 1 commit intomainfrom
log/flags-difc-debug-logging-fa3cd2c4928dd52a

Conversation

@github-actions
Copy link
Contributor

Adds debugLog calls to internal/cmd/flags_difc.go to improve troubleshooting of DIFC (guards) policy configuration at startup.

File modified

internal/cmd/flags_difc.go — reuses the existing package-level debugLog = logger.New("cmd:root") declared in root.go. No new logger declaration or imports needed.

Logging added

getDefaultDIFCMode (2 calls)

  • Logs when MCP_GATEWAY_GUARDS_MODE env var is used and its value is valid
  • Logs when the env var value is invalid and the fallback default (strict) is used

buildAllowOnlyPolicy (4 calls)

  • Entry: logs all input parameters (public, owner, repo, minIntegrity) for full context
  • Short-circuit path: logs when no scope/integrity is set, returning nil policy
  • Scope resolved: logs the final repos value and resolved integrity level
  • Success: logs that policy was built and validated successfully

parseDIFCSinkServerIDs (3 calls)

  • Entry: logs the raw input string being parsed
  • Duplicate detection: logs each deduplicated server ID that was skipped
  • Result: logs the count and list of unique resolved server IDs

Quality checklist

  • Exactly 1 file modified
  • No test files modified
  • Reuses existing debugLog logger (no new declaration needed)
  • Logger namespace follows pkg:filename convention (cmd:root)
  • No side effects in log arguments (all are existing local variables)
  • Messages are meaningful and contextual
  • No duplication with existing log calls
  • Import statements unchanged

Generated by Go Logger Enhancement ·

Add debugLog calls to three functions in flags_difc.go to improve
troubleshooting of DIFC policy configuration:

- getDefaultDIFCMode: log when MCP_GATEWAY_GUARDS_MODE env var is used
  (both valid and invalid values) to clarify which mode was selected
- buildAllowOnlyPolicy: log entry parameters, nil policy short-circuit,
  resolved scope, and successful policy construction
- parseDIFCSinkServerIDs: log parsing start, duplicate deduplication,
  and final resolved server ID list

All logging reuses the existing package-level debugLog variable
(cmd:root namespace) — no new imports or declarations needed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions bot added automation enhancement New feature or request labels Mar 13, 2026
@lpcox lpcox marked this pull request as ready for review March 13, 2026 17:15
Copilot AI review requested due to automatic review settings March 13, 2026 17:15
@lpcox lpcox merged commit b774ac4 into main Mar 13, 2026
3 checks passed
@lpcox lpcox deleted the log/flags-difc-debug-logging-fa3cd2c4928dd52a branch March 13, 2026 17:15
Copy link
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 logging to internal/cmd/flags_difc.go to improve observability of DIFC (guards) policy configuration at startup, covering mode resolution, policy building, and sink server ID parsing.

Changes:

  • Adds 9 debugLog calls across three functions (getDefaultDIFCMode, buildAllowOnlyPolicy, parseDIFCSinkServerIDs) to trace environment variable resolution, policy construction, and input parsing
  • Reuses the existing package-level debugLog logger with no new imports or declarations

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

You can also share your feedback on Copilot code review. Take the survey.

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