fix: suppress false-positive warnings for default EventFlushIntervalMS and ConfigPollingIntervalMS#307
Merged
Conversation
…S and ConfigPollingIntervalMS
There was a problem hiding this comment.
Pull request overview
This PR updates Options.CheckDefaults() to treat zero-valued time.Duration option fields as “unset” so defaults are applied without emitting misleading warnings during typical client initialization.
Changes:
- Apply the default
EventFlushIntervalMS(30s) silently when the value is0. - Apply the default
ConfigPollingIntervalMS(10s) silently when the value is0. - Preserve warnings (and defaulting) for non-zero values that are out of the allowed range.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
JamieSinn
approved these changes
May 4, 2026
…s tests, fix lint go-version
Comment on lines
+16
to
+19
| } | ||
|
|
||
| func TestCheckDefaults_OutOfRange_AppliesDefaults(t *testing.T) { | ||
| o := &Options{ |
Comment on lines
+10
to
+16
| func TestCheckDefaults_ZeroValues_AppliesDefaults(t *testing.T) { | ||
| o := &Options{} | ||
| o.CheckDefaults() | ||
|
|
||
| assert.Equal(t, time.Second*30, o.EventFlushIntervalMS) | ||
| assert.Equal(t, time.Second*10, o.ConfigPollingIntervalMS) | ||
| } |
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.
Summary
EventFlushIntervalMSandConfigPollingIntervalMSaretime.Durationfields, so they zero-value to0whenOptionsis omitted or partially configuredCheckDefaultstreated0as an out-of-range value and emitted aWARNlog even though no misconfiguration occurredBefore / After
Before — initializing with no options produces two spurious warnings:
After — no warnings; defaults are applied silently:
The warning still fires as expected when a value is explicitly set out of range:
Notes
Should we also treat passing
nilforOptionsas equivalent to&Options{}? Right now callers have to pass at least an empty struct to avoid a nil pointer — might be worth checking ifNewClientguards against that, or if we want to add that convenience.