Skip to content

feat: add provider status to client (#205)#237

Open
mstepien wants to merge 9 commits into
open-feature:mainfrom
mstepien:205-add-provider-status-to-client
Open

feat: add provider status to client (#205)#237
mstepien wants to merge 9 commits into
open-feature:mainfrom
mstepien:205-add-provider-status-to-client

Conversation

@mstepien
Copy link
Copy Markdown

@mstepien mstepien commented Apr 16, 2026

Provider status at Client

Implements a synchronous provider status accessor across the core SDK to fully align with OpenFeature Specifications requirements 1.7.1 and 1.7.2.1.

  • Adds getProviderStatus(): OpenFeatureStatus binding to the Client interface and Native OpenFeatureClient implementation.
  • Surfaces the RECONCILING state under the static-context paradigm whenever global evaluation contexts are swapped, matching upstream specification requirements.

Related Issues

Fixes #205

Notes

Opted to retain fun getProviderStatus() over converting it to an idiomatic Kotlin property block inside the interface.

How to test

Run the test block directly in your CLI using:
./gradlew :kotlin-sdk:testDebugUnitTest --tests "dev.openfeature.kotlin.sdk.OpenFeatureClientTests"

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a getProviderStatus method to the Client interface and its implementation in OpenFeatureClient, updating the public API and adding unit tests for various provider states. The review feedback suggests refactoring this method into a Kotlin property named providerStatus to follow idiomatic Kotlin conventions and ensure consistency with the existing statusFlow property.

Comment thread kotlin-sdk/src/commonMain/kotlin/dev/openfeature/kotlin/sdk/Client.kt Outdated
Comment thread kotlin-sdk/src/commonMain/kotlin/dev/openfeature/kotlin/sdk/OpenFeatureClient.kt Outdated
Signed-off-by: Marcin Stepien <marcin.stepien@fluxon.com>
@mstepien mstepien force-pushed the 205-add-provider-status-to-client branch from 7680474 to 96568be Compare April 16, 2026 14:01
@mstepien mstepien marked this pull request as ready for review April 16, 2026 14:18
@maxnrp
Copy link
Copy Markdown
Contributor

maxnrp commented Apr 17, 2026

Looks good and spec-compliant. Nothing to add from my side.

Copy link
Copy Markdown
Contributor

@typotter typotter left a comment

Choose a reason for hiding this comment

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

Review findings

Missing test coverage (no existing line to anchor these to):

Fatal status untestedgetProviderStatus() is never tested for OpenFeatureStatus.Fatal. BrokenInitProvider throws ProviderNotReadyError (which maps to Error), not ProviderFatalError, so the Fatal branch is never exercised through the new accessor. Add a FatalInitProvider helper analogous to BrokenInitProvider that throws ProviderFatalError, call setProviderAndWait, and assert client.getProviderStatus() is OpenFeatureStatus.Fatal.

NotReady status untested — No test confirms that getProviderStatus() returns NotReady before any provider is set. Add a test that calls OpenFeatureAPI.getClient() without first calling setProvider/setProviderAndWait and asserts client.getProviderStatus() == OpenFeatureStatus.NotReady.

Stale status untestedOpenFeatureStatus.Stale is reachable via ProviderStale emission but is never exercised through the new accessor. OverlyEmittingProvider is already in helpers — trigger a ProviderStale emission and assert client.getProviderStatus() == OpenFeatureStatus.Stale.


CHANGELOG — No entry for the new getProviderStatus() public API surface. Add under the next unreleased section:

* Add `getProviderStatus()` to `Client` interface to expose provider status synchronously (spec 1.7.1)

Comment thread kotlin-sdk/src/commonMain/kotlin/dev/openfeature/kotlin/sdk/Client.kt Outdated
Comment thread kotlin-sdk/src/commonMain/kotlin/dev/openfeature/kotlin/sdk/Client.kt Outdated
Signed-off-by: Marcin Stepien <marcin.stepien@fluxon.com>
Signed-off-by: Marcin Stepien <marcin.stepien@fluxon.com>
Signed-off-by: Marcin Stepien <marcin.stepien@fluxon.com>
Comment thread kotlin-sdk/src/commonMain/kotlin/dev/openfeature/kotlin/sdk/Client.kt Outdated
@typotter
Copy link
Copy Markdown
Contributor

Consider adding a test that calls getBooleanDetails immediately after setProvider (before initialization completes) and asserts the returned FlagEvaluationDetails has errorCode == ErrorCode.PROVIDER_NOT_READY.

@typotter
Copy link
Copy Markdown
Contributor

The Fatal branch in shortCircuitIfNotReady() has no test coverage after the refactor to delegate through getProviderStatus(). A regression where ProviderFatalError is not thrown would go undetected.

Consider adding a test using a provider whose initialize throws OpenFeatureError.ProviderFatalError, then evaluating a flag and asserting the details have errorCode == ErrorCode.PROVIDER_FATAL.

Signed-off-by: Marcin Stepien <marcin.stepien@fluxon.com>
Signed-off-by: Marcin Stepien <marcin.stepien@fluxon.com>
Signed-off-by: Marcin Stepien <marcin.stepien@fluxon.com>
@mstepien mstepien force-pushed the 205-add-provider-status-to-client branch from 2c30735 to c82eef6 Compare April 22, 2026 10:29
@mstepien mstepien requested a review from typotter April 22, 2026 13:07
@mstepien
Copy link
Copy Markdown
Author

mstepien commented Apr 22, 2026

The Fatal branch in shortCircuitIfNotReady() has no test coverage after the refactor to delegate through getProviderStatus(). A regression where ProviderFatalError is not thrown would go undetected.

Consider adding a test using a provider whose initialize throws OpenFeatureError.ProviderFatalError, then evaluating a flag and asserting the details have errorCode == ErrorCode.PROVIDER_FATAL.

Has been covered by OpenFeatureClientTests.testClientEvaluationShouldReturnProviderFatalWhenEvaluatingWithFatalProvider() of c82eef6 test: harden error mappings, state flow (#205)

if (providerStatus == OpenFeatureStatus.NotReady) {
throw OpenFeatureError.ProviderNotReadyError()
} else if (providerStatus is OpenFeatureStatus.Fatal) {
throw OpenFeatureError.ProviderFatalError()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not your code, but while you're here, we should propagate the underlying error

Suggested change
throw (providerStatus as OpenFeatureStatus.Fatal).error

mstepien added 2 commits May 8, 2026 11:25
Updated string keys for telemetry events to align with the OpenFeature specification Appendix D and OpenTelemetry Semantic Convention Release v1.33.0 and v1.34.0.
Signed-off-by: Marcin Stepien <marcin.stepien@fluxon.com>
Updated test coverage.
Updated Telemetry.kt to omit missing provider name and context ID entirely
from the OpenTelemetry payload instead of sending empty strings or null values.
This aligns with OpenTelemetry best practices for handling absent data.
Signed-off-by: Marcin Stepien <marcin.stepien@fluxon.com>
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.

Add Provider Status to Client

4 participants