Repository navigation
Commit bcf5a39
fix: Include an error code in provider error events (#68)
**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)
- [ ] I have validated my changes against all supported platform
versions
**Related issues**
OFP requirement 5.1.5 (sdk-specs `OFP-openfeature-provider-behavior`):
`PROVIDER_ERROR` events SHOULD populate the event details' error code.
**Describe the solution you've provided**
When the LaunchDarkly data source transitions to `OFF`, the emitted
`PROVIDER_ERROR` event details now include `ErrorCode.GENERAL` alongside
the existing message:
```java
emitProviderError(ProviderEventDetails.builder().message(message).errorCode(ErrorCode.GENERAL).build());
```
Added `LifeCycleTest.itIncludesAnErrorCodeInErrorEvents`.
**Describe alternatives you've considered**
A more specific code (e.g. `PROVIDER_FATAL` for 401/403) was not used;
OFP does not define a mapping, and the Python provider already uses
`GENERAL` for the same transition. Choosing per-error codes would be a
cross-SDK decision.
**Additional context**
OpenFeature Java SDK 1.23.0 fixed propagation of `errorCode` from
provider event details to handler `EventDetails`, so handlers now
observe this value.
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-3254](https://launchdarkly.atlassian.net/browse/SDK-3254)
[SDK-3254]:
https://launchdarkly.atlassian.net/browse/SDK-3254?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Overview**
> Aligns **PROVIDER_ERROR** event details with OpenFeature provider
behavior (OFP 5.1.5) by setting **`ErrorCode.GENERAL`** when the
LaunchDarkly data source enters **`OFF`** and the provider moves to
error state. Error messages are unchanged; handlers can now read
**`detail.getErrorCode()`** (supported after OpenFeature Java SDK
1.23.0).
>
> Adds **`LifeCycleTest.itIncludesAnErrorCodeInErrorEvents`** to assert
the error code on **`PROVIDER_ERROR`** using the existing delayed
failing data source setup.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
dd3f67a. 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>1 parent 2363198 commit bcf5a39
2 files changed
Lines changed: 21 additions & 1 deletion
File tree
- src
- main/java/com/launchdarkly/openfeature/serverprovider
- test/java/com/launchdarkly/openfeature/serverprovider
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
230 | | - | |
| 230 | + | |
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
357 | 358 | | |
358 | 359 | | |
359 | 360 | | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
360 | 380 | | |
361 | 381 | | |
362 | 382 | | |
| |||
0 commit comments