Fix typos and wrong types in remote_config.py

Đang mở Phù hợp với người mới
#957 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

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

Hướng nghiên cứu

Bắt đầu trong firebase_admin/remote_config.py, đọc evaluate_custom_signal_condition và _Value.as_int() cùng với phần xử lý kiểu dữ liệu ở gần đó. Kiểm tra các giá trị fallback và chú thích kiểu trả về theo issue, sau đó chạy các bài kiểm thử remote-config liên quan của repository nếu có; hoàn tất có nghĩa là các giá trị mặc định và chú thích khớp với kiểu trường tương ứng mà không gây ra hồi quy.

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

Mô tả

api: remoteconfig
[READ] Step 1: Are you in the right place?

This is a bug in the code of this repository (firebase_admin/remote_config.py).


[REQUIRED] Step 2: Describe your environment
  • Operating System version: Windows 11
  • Firebase SDK version: 6.x (latest)
  • Firebase Product: remote_config
  • Python version: 3.11
  • Pip version: 24.x

[REQUIRED] Step 3: Describe the problem
Steps to reproduce:

In firebase_admin/remote_config.py, the method evaluate_custom_signal_condition
uses {} (empty dict) as the default fallback for string and list fields:

custom_signal_operator = custom_signal_condition.get('customSignalOperator') or {}
custom_signal_key = custom_signal_condition.get('customSignalKey') or {}
target_custom_signal_values = custom_signal_condition.get('targetCustomSignalValues') or {}

These should be '' (string) and [] (list) respectively, as the fields are
not dicts. Using {} is semantically incorrect.

Also, _Value.as_int() has a wrong return type annotation -> float instead
of -> int.

Relevant Code:
# Wrong defaults — should be '' and []
custom_signal_operator = custom_signal_condition.get('customSignalOperator') or {}
custom_signal_key = custom_signal_condition.get('customSignalKey') or {}
target_custom_signal_values = custom_signal_condition.get('targetCustomSignalValues') or {}

# Wrong return type annotation — should be -> int
def as_int(self) -> float:
    """Returns the value as a number."""
Ngôn ngữ chính
Python
Star
1.2k
Fork
359
Merge trung bình
5 ngày 6 phút
Pull request đã merge (30 ngày)
2

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

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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của firebase/firebase-admin-python

Tất cả issue của firebase/firebase-admin-python

Issue tương tự

Thêm issue về Python

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.