Skip to content

fix: suppress false-positive warnings for default EventFlushIntervalMS and ConfigPollingIntervalMS#307

Merged
jonathannorris merged 6 commits into
mainfrom
fix/suppress-default-interval-warnings
May 8, 2026
Merged

fix: suppress false-positive warnings for default EventFlushIntervalMS and ConfigPollingIntervalMS#307
jonathannorris merged 6 commits into
mainfrom
fix/suppress-default-interval-warnings

Conversation

@jonathannorris

Copy link
Copy Markdown
Member

Summary

  • EventFlushIntervalMS and ConfigPollingIntervalMS are time.Duration fields, so they zero-value to 0 when Options is omitted or partially configured
  • CheckDefaults treated 0 as an out-of-range value and emitted a WARN log even though no misconfiguration occurred
  • Zero is now handled as "unset" — the default is applied silently; the warning only fires for explicitly-set out-of-range values

Before / After

Before — initializing with no options produces two spurious warnings:

client, err := devcycle.NewClient(sdkKey, &devcycle.Options{})
// WARN: EventFlushIntervalMS cannot be less than 500ms or longer than 1 minute. Defaulting to 30 seconds.
// WARN: ConfigPollingIntervalMS cannot be less than 1 second. Defaulting to 10 seconds.

After — no warnings; defaults are applied silently:

client, err := devcycle.NewClient(sdkKey, &devcycle.Options{})
// (no warnings)

The warning still fires as expected when a value is explicitly set out of range:

client, err := devcycle.NewClient(sdkKey, &devcycle.Options{
    EventFlushIntervalMS: 100 * time.Millisecond, // too low — will warn
})

Notes

Should we also treat passing nil for Options as equivalent to &Options{}? Right now callers have to pass at least an empty struct to avoid a nil pointer — might be worth checking if NewClient guards against that, or if we want to add that convenience.

Copilot AI review requested due to automatic review settings April 29, 2026 16:01
@jonathannorris jonathannorris requested a review from a team as a code owner April 29, 2026 16:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 is 0.
  • Apply the default ConfigPollingIntervalMS (10s) silently when the value is 0.
  • 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.

Comment thread configuration.go Outdated
Comment thread configuration.go Outdated
Comment thread configuration.go
Copilot AI review requested due to automatic review settings May 6, 2026 20:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread configuration_test.go
Comment on lines +16 to +19
}

func TestCheckDefaults_OutOfRange_AppliesDefaults(t *testing.T) {
o := &Options{
Copilot AI review requested due to automatic review settings May 8, 2026 17:51
@jonathannorris jonathannorris enabled auto-merge (squash) May 8, 2026 17:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread configuration_test.go
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)
}
@jonathannorris jonathannorris merged commit 3566cdd into main May 8, 2026
16 checks passed
@jonathannorris jonathannorris deleted the fix/suppress-default-interval-warnings branch May 8, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants