Skip to content

Commit 17478dc

Browse files
fix: Map the WRONG_TYPE error kind to TYPE_MISMATCH (#57)
The `WRONG_TYPE` evaluation error kind is now reported as `ErrorCode.TYPE_MISMATCH` instead of falling through to `GENERAL`. - Required by the OFP spec's error kind mapping - Brings the Python provider in line with the Ruby and .NET providers, which already map it <details> <summary>Implementation details</summary> Found during the weekly OpenFeature provider audit against `launchdarkly/sdk-specs` (`OFP`). `ResolutionDetailsConverter` mapped `CLIENT_NOT_READY`, `FLAG_NOT_FOUND`, `MALFORMED_FLAG` and `USER_NOT_SPECIFIED`, and every other kind — including `WRONG_TYPE` — became `GENERAL`, hiding a type mismatch from callers that branch on the error code. `EXCEPTION_ERROR` intentionally remains mapped to `GENERAL`. **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** None. **Describe alternatives you've considered** None; the mapping is prescribed by the spec. **Testing** `poetry run pytest` (80 passed), `poetry run mypy ld_openfeature tests` </details> Link to Devin session: https://app.devin.ai/sessions/38a6eaf69fcf41109e136a1d0fe5e899 Requested by: @kinyoklion <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Overview** > LaunchDarkly evaluation errors with **`errorKind: WRONG_TYPE`** are now converted to OpenFeature **`ErrorCode.TYPE_MISMATCH`** in `ResolutionDetailsConverter`, instead of defaulting to **`GENERAL`**. > > A parametrized test covers the new mapping so callers that branch on error codes can detect type mismatches per the OpenFeature provider spec (aligned with other LaunchDarkly providers). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 20eada9. 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 946a515 commit 17478dc

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

‎ld_openfeature/impl/details_converter.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ def __error_kind_to_code(error_kind: Optional[str]) -> ErrorCode:
100100
return ErrorCode.PARSE_ERROR
101101
elif error_kind == 'USER_NOT_SPECIFIED':
102102
return ErrorCode.TARGETING_KEY_MISSING
103+
elif error_kind == 'WRONG_TYPE':
104+
return ErrorCode.TYPE_MISMATCH
103105

104106
# NOTE: EXCEPTION_ERROR intentionally omitted
105107

‎tests/impl/test_details_converter.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def test_ld_to_openfeature_kind_mappings(detail_kind: str, reason: Union[str, Re
3838
pytest.param('FLAG_NOT_FOUND', ErrorCode.FLAG_NOT_FOUND),
3939
pytest.param('MALFORMED_FLAG', ErrorCode.PARSE_ERROR),
4040
pytest.param('USER_NOT_SPECIFIED', ErrorCode.TARGETING_KEY_MISSING),
41+
pytest.param('WRONG_TYPE', ErrorCode.TYPE_MISMATCH),
4142
pytest.param('EXCEPTION_ERROR', ErrorCode.GENERAL),
4243
],
4344
)

0 commit comments

Comments
 (0)