Skip to content

fix: Include the last data source error in provider error and stale events - #74

Open
kinyoklion wants to merge 2 commits into
mainfrom
devin/1790779570-error-event-message
Open

kinyoklion wants to merge 2 commits into
mainfrom
devin/1790779570-error-event-message

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

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

OFP requirements 4.2.3 / 4.2.4 (sdk-specs OFP-openfeature-provider-behavior): STALE/ERROR events MUST include the message of the last data source error, or a message describing the condition if it has none. The Java provider already does this.

Describe the solution you've provided

private static string DescribeLastError(DataSourceStatus status, string fallback)
    => status.LastError is ErrorInfo e ? e.Message ?? e.ToString() : fallback;
  • Off (both in StatusChangeHandler and the InitializeAsync pre-check): PROVIDER_ERROR message and the LaunchDarklyProviderInitException message now use DescribeLastError(status, ProviderShutdownMessage) instead of always ProviderShutdownMessage.
  • Interrupted: previously LastError?.Message ?? "encountered an unknown error", so HTTP errors (which have no Message) got the generic text; they now get ErrorInfo.ToString() (e.g. kind + status code).

Behavior is unchanged when there is no LastError. Added tests for Off with an exception message, Off with an HTTP 401, Off with no error, and Interrupted with an HTTP 503.

Describe alternatives you've considered

Always using ErrorInfo.ToString() would also include the timestamp for exception-based errors; Message is kept when present so existing Stale messages do not change.

Additional context

Validated locally with dotnet test on net8.0 (72 passed). Independent of the error-type PR (#73).

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

SDK-3255


Note

Overview
Provider error and stale events now surface the LaunchDarkly data source’s last error instead of only generic shutdown or “unknown error” text, aligning with OpenFeature provider behavior (OFP 4.2.3 / 4.2.4).

A new DescribeLastError helper picks ErrorInfo.Message when present, otherwise ErrorInfo.ToString() (so HTTP failures without a message still describe status codes). That message is used for PROVIDER_ERROR / init failures when the data source is Off (including the InitializeAsync pre-check) and for PROVIDER_STALE when state is Interrupted. When there is no LastError, behavior stays the same via the existing fallback strings.

Tests cover exception messages, HTTP 401/503 cases, and the default message when LastError is absent.

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

…vents

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

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

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

This branch has not been deployed

No deployments
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.

1 participant