Flagsmith / Flagsmith/flagsmith-python-client

Identity overrides don't work in offline local evaluation mode

Đang mở
#109 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
24
Fork
12
Merge trung bình
15 giờ 43 phút
Pull request đã merge (30 ngày)
4

Mô tả

I'm using version 3.8.0 and have identity overrides enabled for my environment.

I'm using a copy of a config for local development and initialize Flagsmith as follows:
```
local_file_handler = LocalFileHandler(
environment_document_path=f"./feature_flags_configuration.local.json"
)
flagsmith = Flagsmith(
environment_key=settings.FLAGSMITH_API_KEY,
enable_local_evaluation=True,
offline_handler=local_file_handler,
offline_mode=True,
)
```

I have following settings on my config:
```
"feature_states": [
{
"feature": {
"id": 103972,
"name": "ipqs_geo_ip",
"type": "STANDARD"
},
"enabled": true,
"django_id": 576867,
"feature_segment": null,
"featurestate_uuid": "04dcc7d5-b387-4668-8264-d30a2da2e111",
"feature_state_value": null,
"multivariate_feature_state_values": []
}
],
"identity_overrides": [
{
"identifier": "146433",
"environment_api_key": ...,
"created_date": "2024-08-26T17:45:31.959128Z",
"identity_features": [
{
"feature": {
"id": 103972,
"name": "ipqs_geo_ip",
"type": "STANDARD"
},
"enabled": false,
"django_id": null,
"feature_segment": null,
"featurestate_uuid": "964dd1e9-b34a-4bf7-9984-937abbba3f0e",
"feature_state_value": null,
"multivariate_feature_state_values": []
}
],
"identity_traits": [],
"identity_uuid": "8fd6de03-b834-41d2-b5ec-7076d00e6cd3",
"django_id": null,
"composite_key": "cfWNJQwEQkcAiKxSPFL2rv_146433"
}
],
```

However, identity overrides are ignored unless I disable offline mode.

The root cause must be that it is updated only [here](https://github.com/Flagsmith/flagsmith-python-client/blob/56cdcc1c9f0596bb40466fd4d42c0a30fbb6633b/flagsmith/flagsmith.py#L273) when API request is made and are not loaded from offline handler [here](https://github.com/Flagsmith/flagsmith-python-client/blob/56cdcc1c9f0596bb40466fd4d42c0a30fbb6633b/flagsmith/flagsmith.py#L117).

In production, I'm also using the local file as a fallback for the case when Flagsmith is unavailable during app start, so it might become a problem in production in rare cases.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu trong flagsmith/flagsmith.py tại đường dẫn tải offline-handler quanh dòng 117 và đường dẫn cập nhật API quanh dòng 273; theo dõi cách identity_overrides được biểu diễn trong tệp cục bộ. Xác minh rằng việc đánh giá cục bộ offline áp dụng override cho mã định danh 146433 trong khi vẫn giữ nguyên hành vi trạng thái tính năng thông thường, đồng thời thêm hoặc chạy coverage hồi quy cho trường hợp này.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
backend
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.