Skip to content

fix!: Use None rather than zero for indefinite initialization waiting - #64

Merged
kinyoklion merged 7 commits into
mainfrom
devin/1789569799-python-indefinite-start-wait
Oct 28, 2026
Merged

kinyoklion merged 7 commits into
mainfrom
devin/1789569799-python-indefinite-start-wait

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

Aligns start_wait with the OpenFeature provider spec (OFP), which requires a distinct non-duration value to request indefinite initialization waiting.

  • start_wait=None now requests an indefinite wait: the constructor does not block and initialize waits until the data source becomes valid or fails permanently.
  • start_wait=0 no longer waits indefinitely; it waits nowhere, so initialize reports a failed initialization unless the client is already ready, and readiness is observed through provider events.
  • Positive values are unchanged: the constructor bounds the wait and initialize returns immediately with whatever the outcome is.
  • Breaking for anyone relying on 0 meaning "wait forever".

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

None.

Implementation details

OFP requires that a positive start wait bound total construction plus initialization, that zero wait nowhere, and that indefinite waiting avoid construction-time blocking and instead wait during initialize. Previously zero was overloaded to mean indefinite, leaving no way to express "no waiting at all".

None is now passed to LDClient as a zero construction wait, with the waiting performed in initialize against the data source status listener.

Testing: make test (88 tests) and make lint (mypy) pass. New tests cover the zero and indefinite cases, including that the constructor does not block when None is given.

Link to Devin session: https://app.devin.ai/sessions/1fd3fcbfe79f482e8b58be29e8df2ffb
Open in Devin Desktop: https://app.devin.ai/desktop/session/1fd3fcbfe79f482e8b58be29e8df2ffb?variant=devin
Requested by: @kinyoklion

SDK-3285


Note

Overview
Breaking change: start_wait now matches the OpenFeature provider contract instead of overloading 0 for “wait forever.”

start_wait=None means indefinite waiting only inside initialize (constructor passes 0 to LDClient so it does not block). start_wait=0 means no waiting anywhere—initialize fails immediately unless the client is already ready, and later readiness is surfaced via provider events. Positive values are unchanged.

Provider lifecycle updates track ProviderStatus, register data-source listeners before the readiness check, suppress duplicate events during initialization, and still emit PROVIDER_READY if the data source becomes valid after a failed init. README marks initialization fully supported; tests add DelayedReadyDataSource and cases for zero vs None and post-failure ready events.

Reviewed by Cursor Bugbot for commit 9dc4c47. Bugbot is set up for automated code reviews on this repo. Configure here.


AI review comment: the override below pins the next release to 0.9.0 — this repo's release-please config lacks bump-minor-pre-major, so this PR's fix!: commit escalated the open release PR to 1.0.0 instead of 0.9.0. A config fix is in flight; this override makes the correction effective on the next release-please run regardless.

BEGIN_COMMIT_OVERRIDE
fix!: Use None rather than zero for indefinite initialization waiting (#64)

start_wait=None now requests an indefinite wait performed in initialize();
start_wait=0 waits nowhere and reports failed initialization unless the
client is already ready. Breaking for anyone relying on 0 meaning "wait forever".

Release-As: 0.9.0
END_COMMIT_OVERRIDE

Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration

Copy link
Copy Markdown
Contributor

@cursor review

@kinyoklion

Copy link
Copy Markdown
Member Author

Devin check this against the latest version of the spec.

@kinyoklion
kinyoklion marked this pull request as ready for review September 29, 2026 22:47
@kinyoklion
kinyoklion requested a review from a team as a code owner September 29, 2026 22:47
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6385f3e. Configure here.

Comment thread ld_openfeature/provider.py Resolved
Comment thread tests/test_provider.py Resolved
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

Devin check this against the latest version of the spec.

Rechecked against the latest OFP spec (launchdarkly/sdk-specs at 7085813, "Clarify OpenFeature provider start wait behavior"). The start_wait semantics in this PR still match 4.3.4–4.3.7; the gap found was 4.3.3, the provider must keep reporting status changes after initialization has failed.

  • The data source and flag listeners now stay registered after a failed initialization, and provider status is tracked so only genuine transitions are emitted.
  • The initialization outcome is recorded and initialization completed under the same lock, so the OpenFeature SDK's own event for the initialization outcome is not duplicated (4.2.5) and a concurrent data source change cannot be dropped.
  • Added test_ready_is_reported_after_initialization_failed.

poetry run pytest -q: 89 pass. poetry run mypy ld_openfeature tests: clean.

Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>

# Conflicts:
#	ld_openfeature/provider.py
#	tests/test_provider.py
kinyoklion added a commit to launchdarkly/js-core that referenced this pull request Oct 9, 2026
Gives the OpenFeature providers the initialization waiting values the
OpenFeature provider spec (OFP) requires, which the numeric-only
`initTimeoutSeconds` could not express.

- `initTimeoutSeconds: 'forever'` waits indefinitely for the
LaunchDarkly client
- `initTimeoutSeconds: 0` waits nowhere and fails initialization unless
the client is already ready, so readiness is observed through provider
events
- A positive timeout behaves as before, and the default is still 10
seconds
- Node provider README feature matrix row updated for the new values

<details>
<summary>Implementation details</summary>

**Requirements**

- [x] I have added test coverage for new or changed functionality
- [x] I have followed the repository's [pull request submission
guidelines](../blob/main/CONTRIBUTING.md#submitting-pull-requests)
- [x] I have validated my changes against all supported platform
versions

**Related issues**

OFP requirement 4.3.4 requires a value distinct from any duration to
request waiting indefinitely, and 4.3.6 requires a zero wait to wait
nowhere and fail initialization. Sibling changes for the same
requirement: launchdarkly/openfeature-java-server#66,
launchdarkly/openfeature-python-server#64,
launchdarkly/openfeature-dotnet-server#71,
launchdarkly/openfeature-ruby-server#36.

**Describe the solution you've provided**

`BaseProviderConfig.initTimeoutSeconds` and the Node provider's
constructor parameter are now `number | 'forever'`, and zero is no
longer coalesced into the default, since `??` only replaces `undefined`.
`waitForInitialization` treats a falsy timeout as no timeout, so zero
cannot be passed through: initialization races the pending
initialization promise against an immediately rejected one, which
succeeds only when the client is already ready.

The Cloudflare provider is unaffected because it evaluates from a KV
namespace and has no data source to wait for.

**Describe alternatives you've considered**

`number | null` was used initially for the indefinite case; `'forever'`
reads better at the call site and matches the repository's preference
for string unions. Adding `initialized()` to the client contract would
let the zero case be checked directly, but that is a breaking change to
a published interface for behavior the existing promise already
expresses.

**Additional context**

Verified with `yarn workspace @launchdarkly/openfeature-js-server-common
test` (82 tests), `yarn workspace @launchdarkly/openfeature-node-server
test` (29 tests), and lint, format and build checks for both packages.

</details>

Link to Devin session:
https://app.devin.ai/sessions/1fd3fcbfe79f482e8b58be29e8df2ffb
Open in Devin Desktop:
https://app.devin.ai/desktop/session/1fd3fcbfe79f482e8b58be29e8df2ffb?variant=devin
Requested by: @kinyoklion

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> Extends **`initTimeoutSeconds`** on the shared
**`BaseOpenFeatureProvider`** and the Node **`LaunchDarklyProvider`** to
**`number | 'forever'`**, aligning initialization with the OpenFeature
provider spec.
> 
> **`'forever'`** calls **`waitForInitialization()`** with no timeout.
**`0`** no longer falls through to the 10-second default (only
**`undefined`** does); initialization races the client’s init promise
against an immediate failure so it succeeds only when the client is
already ready, otherwise it throws a clear error. Positive timeouts
behave as before (default **10** seconds).
> 
> The Node provider README initialization row documents the new values,
and unit tests cover indefinite wait, zero-timeout failure, and
zero-timeout success when already ready.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
87e9a23. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
kinyoklion added a commit that referenced this pull request Oct 13, 2026
… row (#68)

## Summary

LaunchDarkly Python SDK 9.18.0 made a rejected SDK key retryable rather
than permanently stopping the data source. The README says
`start_wait=0` waits "until the data source becomes valid or permanently
fails", but a rejected key now never permanently fails. With zero,
`initialize` therefore never completes while the key is rejected.

- Initialization row: now ⚠️, notes the SDK 9.18.0 behavior, and marks
the provider gap (zero should mean "do not wait", per OFP 4.3.6),
tracked by
[#64](#64).
- The `start_wait` paragraph gets the same note.

<details>
<summary>Details</summary>

I checked this locally with `launchdarkly-server-sdk` 9.18.1 and an
invalid key. The data source stayed `INITIALIZING`, and `last_error`
reported `ERROR_RESPONSE 401` while it retried. It never reported `OFF`.

The provider allows `launchdarkly-server-sdk >=9.17.0,<10`, so new
installs get the retry behavior. #64 also edits these lines. Whichever
merges second will need a small README conflict fix.

Found in the weekly OpenFeature provider audit. Docs-only change.
</details>

Link to Devin session:
https://app.devin.ai/sessions/c8bc4e80339b473882c2dddffe981edf
Open in Devin Desktop:
https://app.devin.ai/desktop/session/c8bc4e80339b473882c2dddffe981edf?variant=devin
Requested by: @kinyoklion

[SDK-3286](https://launchdarkly.atlassian.net/browse/SDK-3286)


[SDK-3286]:
https://launchdarkly.atlassian.net/browse/SDK-3286?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> Updates **README** to reflect LaunchDarkly Python SDK **9.18.0+**
behavior: a rejected SDK key is **retried** instead of permanently
failing the data source.
> 
> The **Initialization** feature matrix row is downgraded from ✅ to
**⚠️**, with notes that `start_wait=0` can wait indefinitely on a bad
key and that the provider still has a gap (zero should mean “do not
wait” per OpenFeature), linked to **#64**. The **`start_wait`**
getting-started paragraph adds the same SDK 9.18.0 caveat so it matches
the matrix.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
4b2f0cc. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>

# Conflicts:
#	README.md
Comment thread ld_openfeature/provider.py Resolved
Comment thread ld_openfeature/provider.py Resolved
devin-ai-integration Bot and others added 2 commits October 27, 2026 20:42
Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com>
…te-start-wait' into devin/1789569799-python-indefinite-start-wait
@kinyoklion
kinyoklion merged commit 8bff7b3 into main Oct 28, 2026
15 checks passed
@kinyoklion
kinyoklion deleted the devin/1789569799-python-indefinite-start-wait branch October 28, 2026 16:50
tanderson-ld added a commit that referenced this pull request Oct 28, 2026
Adds `bump-minor-pre-major: true` to the release-please config, matching
the Ruby provider repo's configuration.

**Why:** release-please's default versioning strategy escalates a
breaking change to a major bump even below 1.0.0. The `fix!:` in #64
therefore retitled the open release PR #72 to **1.0.0** instead of
**0.9.0**. Crossing to 1.0 should be a deliberate GA decision, not a
side effect of a missing config flag.

**Effect:** merging this PR triggers a release-please run, which will
recompute #72 to 0.9.0 (a `Release-As: 0.9.0` override has also been
added to #64's body as a belt-and-suspenders measure — both mechanisms
agree). The changelog is unchanged and the release remains flagged as
breaking.

With this flag, pre-1.0 breaking changes bump the minor (0.x → 0.(x+1))
going forward.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> Adds **`bump-minor-pre-major`: true** to `release-please-config.json`
so release-please treats breaking changes as **minor** bumps while the
package is still below **1.0.0**, instead of jumping to **1.0.0** by
default.
> 
> This aligns versioning with the Ruby provider repo and keeps a
deliberate **1.0.0** GA cut separate from conventional-commit breaking
changes (e.g. retitling an in-flight release PR from **1.0.0** to
**0.9.0** without changing the breaking changelog content).
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
ae994ba. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
tanderson-ld pushed a commit that referenced this pull request Oct 28, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.9.0](0.8.3...0.9.0)
(2026-10-28)


### ⚠ BREAKING CHANGES

* Use None rather than zero for indefinite initialization waiting
([#64](#64))

### Bug Fixes

* Use None rather than zero for indefinite initialization waiting
([#64](#64))
([8bff7b3](8bff7b3))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> This **Release Please** PR cuts **0.9.0** by bumping the version
everywhere it is published (`pyproject.toml`,
`ld_openfeature/version.py`, Sphinx `docs/conf.py`, and
`.release-please-manifest.json`) and adding the **0.9.0** section to
`CHANGELOG.md`.
> 
> The release notes call out a **breaking change** from
[#64](#64):
**`LaunchDarklyProvider`'s `start_wait` now uses `None` for indefinite
initialization waiting**, not `0`. Callers who relied on `start_wait=0`
to block until ready must pass **`None`** instead; **`0`** now means no
wait in the constructor (same as documented for `LDClient`).
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
4ca60d1. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
kinyoklion added a commit to launchdarkly/openfeature-java-server that referenced this pull request Nov 4, 2026
**Requirements**

- [x] I have added test coverage for new or changed functionality
- [x] I have followed the repository's [pull request submission
guidelines](../blob/main/CONTRIBUTING.md#submitting-pull-requests)
- [x] I have validated my changes against all supported platform
versions

**Related issues**

Fixes #58.

**Describe the solution you've provided**

Adds `Provider(String sdkKey, LDConfig config, Duration startWait)` so
an application can bound, or deliberately opt out of, waiting for
initialization, matching the OpenFeature provider spec (OFP)
requirements for start wait behavior:

- a positive `Duration` is applied by the LaunchDarkly client
constructor, and `initialize` then reports whether the client became
ready without waiting a second time
- `Duration.ZERO` waits nowhere; `initialize` fails unless the client is
already ready, and the application learns when it becomes usable from
provider events
- `Provider.INFINITE_START_WAIT` requests indefinite waiting: nothing is
waited for during construction and `initialize` blocks until the data
source becomes valid or fails permanently

The existing constructors keep honouring
`LDConfig.Builder.startWait(...)` and no longer wait again in
`initialize`, so a configured start wait is the only bound on
initialization instead of being followed by an unbounded wait. The
README feature matrix row and initialization section describe the new
behavior.

<details>
<summary>Implementation details</summary>

`initialize` still registers data source and flag change listeners and
evaluates the current data source status. Only the indefinite mode
leaves the completion future pending; every other mode completes it with
the outcome that is already known, so `initialize` returns promptly.

The OpenFeature SDK emits its own event for the transition that
completes initialization, so the provider records that one state without
emitting a duplicate, and emits every state change after it — including
a permanent failure that arrives immediately after the data source
became valid, and a recovery after a failed initialization.

</details>

**Describe alternatives you've considered**

Keeping the existing indefinite wait and adding a timeout parameter
interpreted only inside `initialize` would double-wait when
`LDConfig.startWait` is also set, and would not match OFP, which treats
the start wait as a bound over construction plus initialization.

Java has no built-in infinite `Duration`, so indefinite waiting was
initially expressed as `null`. It is now the explicit
`Provider.INFINITE_START_WAIT` constant, matching
`Timeout.InfiniteTimeSpan` in the .NET provider.

**Additional context**

Sibling changes for the same OFP requirement:
launchdarkly/openfeature-python-server#64,
launchdarkly/openfeature-ruby-server#36,
launchdarkly/openfeature-dotnet-server#71, and
launchdarkly/js-core#2024.

Verified with `./gradlew test` (all tests pass, including new coverage
for positive, zero, and indefinite start wait).

Link to Devin session:
https://app.devin.ai/sessions/1fd3fcbfe79f482e8b58be29e8df2ffb
Open in Devin Desktop:
https://app.devin.ai/desktop/session/1fd3fcbfe79f482e8b58be29e8df2ffb?variant=devin
Requested by: @kinyoklion

[SDK-3285](https://launchdarkly.atlassian.net/browse/SDK-3285)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> Fixes OpenFeature initialization behavior (**#58**) by adding
**`Provider(String, LDConfig, Duration startWait)`** and
**`Provider.INFINITE_START_WAIT`**, so startup waiting is bounded in one
place instead of blocking again indefinitely inside **`initialize()`**
after **`LDConfig.startWait`**.
> 
> **Positive durations** apply during client construction;
**`Duration.ZERO`** fails fast unless already ready; **indefinite** mode
skips construction blocking and waits in **`initialize()`** until the
data source is valid, fails, or the provider shuts down. Oversized
durations are treated as indefinite to avoid SDK millis overflow.
> 
> **`initialize()`** is reworked around a completion future and tighter
state/event handling: failed init surfaces data-source errors, duplicate
**STALE**/**READY** events are deduped, teardown **OFF** does not emit
**PROVIDER_ERROR**, and **`shutdown()`** calls **`super.shutdown()`** to
stop leaking the event executor. README documents cancellation of
indefinite **`setProviderAndWait`** (direct **`provider.shutdown()`** vs
API lock contention).
> 
> Lifecycle tests cover bounded/zero/infinite waits, recovery, and
classification boundaries.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
1c96e64. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---

## tanderson-ld additional changes

Review-driven hardening of the start wait time behavior, on top of the
commits above. Summary of the delta:

**Indefinite wait is now cancellable.** `shutdown()` completes the
initialization future, and the interrupt flag is restored if the waiting
thread is interrupted. The README and constructor javadoc document how
to cancel an indefinite `setProviderAndWait`: call `provider.shutdown()`
directly from another thread, or register with the non-blocking
`setProvider`. `OpenFeatureAPI.shutdown()` **cannot** end such a wait —
it blocks on the same API lock `setProviderAndWait` holds for the
duration of initialization. This lock-contention deadlock is inherent to
the OpenFeature Java SDK (it holds the API write lock across a
synchronous `initialize()` and contends on it in `shutdown()`), so it is
documented rather than worked around; an upstream issue will be filed
against the OpenFeature Java SDK.

**Start wait time classification / validation.**
- Any start wait time too large to represent in milliseconds — including
`Provider.INFINITE_START_WAIT` and any other "forever" duration — is
classified as indefinite, so it saturates to the indefinite path instead
of overflowing when the SDK converts it to milliseconds. (Separately, a
too-large duration configured through `LDConfig.Builder.startWait`
instead of the constructor still overflows inside the SDK client
constructor and leaks the client; that is pre-existing SDK behavior and
has been filed as a separate java-core ticket. The sentinel is
documented as constructor-argument-only.)
- A `null` start wait time falls through to the SDK's default start wait
rather than throwing.

**Status / event fidelity.**
- A failed initialization carries the data source's last error into the
thrown exception, so the OpenFeature error event reports the cause
rather than a generic message.
- The client's `isInitialized()` latch no longer reports `READY` when
the data source is currently `OFF`.
- Repeated interruptions emit one `PROVIDER_STALE` per state change
(state-based dedupe, retained and documented), and stale events now
carry the HTTP error detail.

**Lifecycle cleanup.** `shutdown()` removes its flag-change and
data-source status listeners and calls `super.shutdown()` to terminate
the event emitter executor.

**Tests.** Added lifecycle coverage for bounded / zero / indefinite
waits, failed-init-then-recovery, interruption → stale → ready,
single-stale-per-outage dedupe, cancellation of an indefinite
`setProviderAndWait` via a direct `provider.shutdown()`, the
`OFF`-while-initialized exclusion, listener removal on shutdown, and a
direct unit test of the start-wait classification boundary. Full suite
and checkstyle pass.


[SDK-3285]:
https://launchdarkly.atlassian.net/browse/SDK-3285?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Todd Anderson <tanderson@launchdarkly.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devin-pr Pull request created by Devin AI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants