Skip to content

[log] Add debug logging to GitHub token/URL resolution in envutil#3684

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
log/envutil-github-token-lookup-1a22585fb2235c88
Draft

[log] Add debug logging to GitHub token/URL resolution in envutil#3684
github-actions[bot] wants to merge 1 commit intomainfrom
log/envutil-github-token-lookup-1a22585fb2235c88

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Summary

Adds debug logging to internal/envutil/github.go to improve visibility into GitHub token and API URL resolution during troubleshooting.

Changes

File modified: internal/envutil/github.go

  • Added logger import and var logGitHub = logger.New("envutil:github")
  • LookupGitHubToken: 3 log calls
    • Entry log showing how many candidate env vars are checked
    • Log which env var key supplied the token (key name only, not the value — secure)
    • Log when no token is found in any candidate var
  • LookupGitHubAPIURL: 2 log calls
    • Log URL when GITHUB_API_URL env var is used
    • Log URL when falling back to the default

Why This Is Useful

LookupGitHubToken is called during auth setup and it's often unclear in production which env var is providing the token (or if one is missing). These logs make that immediately visible when DEBUG=envutil:* is set, without leaking the token value.

Similarly, LookupGitHubAPIURL is called during server startup and knowing whether the URL came from env or defaults helps diagnose routing issues.

Testing

Enable debug logging to see output:

DEBUG=envutil:* ./awmg --config config.toml
```

Expected output:
```
envutil:github Looking up GitHub token: checking 4 candidate env vars
envutil:github GitHub token found: source=GITHUB_TOKEN
envutil:github GitHub API URL using default: https://api.github.com

Generated by Go Logger Enhancement · ● 10M ·

Add logGitHub logger to internal/envutil/github.go to provide visibility
into which environment variable supplies the GitHub token and which URL
source is used for the API base URL.

Changes:
- Add logger import and logGitHub = logger.New("envutil:github")
- LookupGitHubToken: log entry with candidate count, log which env var
  key was used (not the value, for security), log when no token found
- LookupGitHubAPIURL: log whether URL came from GITHUB_API_URL env var
  or the default URL

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions bot added automation enhancement New feature or request labels Apr 13, 2026
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.

0 participants