fix(envutil): route GetIntFromEnv warnings through logger when provided#29195
Merged
fix(envutil): route GetIntFromEnv warnings through logger when provided#29195
Conversation
5 tasks
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/4eda7e1c-777b-4758-8e52-93f1d0b73e82 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix logging bypass in GetIntFromEnv method
fix(envutil): route GetIntFromEnv warnings through logger when provided
Apr 29, 2026
pelikhan
approved these changes
Apr 29, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Updates GetIntFromEnv to route warning output through the provided *logger.Logger (instead of always writing directly to os.Stderr), aiming to make the log parameter reflect actual warning behavior.
Changes:
- Added a local
warnhelper inGetIntFromEnvto centralize warning emission and choose between logger vs. direct stderr output. - Updated parse/out-of-bounds branches to call the shared
warnhelper. - Updated the function comment to reflect logger-based warning routing.
Show a summary per file
| File | Description |
|---|---|
| pkg/envutil/envutil.go | Centralizes warning emission and routes warnings via logger when provided. |
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: 1
Comment on lines
+29
to
+36
| // Invalid values trigger warning messages to stderr, or through the logger if provided. | ||
| func GetIntFromEnv(envVar string, defaultValue, minValue, maxValue int, log *logger.Logger) int { | ||
| warn := func(msg string) { | ||
| if log != nil { | ||
| log.Printf("WARNING: %s", msg) | ||
| } else { | ||
| fmt.Fprintln(os.Stderr, console.FormatWarningMessage(msg)) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GetIntFromEnvaccepted a*logger.Loggerbut only used it for success messages — warnings for invalid/out-of-bounds values always went directly toos.Stderr, making the logger parameter misleading and preventing callers from controlling warning output.Changes
pkg/envutil/envutil.go: Introduced a localwarnclosure that routes throughlog.Printfwhen a logger is provided, falling back tofmt.Fprintln(os.Stderr, ...)only whenlogis nilNo behavior change for callers passing
nilas the logger.