Azure / Azure/azure-sdk-for-python
SecurityCenter().security_contacts list method is not working
- 主要言語
- Python
- スター
- 5.6k
- フォーク
- 3.4k
- 平均マージ
- 2日 2時間
- マージ済み PR(30日)
- 213
説明
- **Package Name**: `azure-mgmt-security`
- **Package Version**: 7.0.0
- **Operating System**: macOS 15.5 (24F74)
- **Python Version**: 3.12.8
**Describe the bug**
The `security_contacts.list()` method does not work out-of-the-box and throws a deserialization error. As described in issue #35996, this can be temporarily resolved by explicitly specifying `api_version="2023-12-01-preview"`.
However, when using this API version, the `alert_notifications` attribute is always None, even though a direct `get()` call for the same contact (e.g., `get("default")`) returns the expected populated value.
Is this a known limitation of the preview API, or is something missing in how the `list()` call is returning objects?
**To Reproduce**
Steps to reproduce the behavior:
**Testing script:**
```
from azure.mgmt.security import SecurityCenter
from azure.identity import DefaultAzureCredential
credential = DefaultAzureCredential()
client = SecurityCenter(credential, "")
# List using default API version (fails)
print("Testing list with default API version")
try:
for contact in client.security_contacts.list():
print(contact)
except Exception as e:
print(f"Error: {e}")
# List using preview API version (works, but missing alert_notifications)
print("Testing list with 2023-12-01-preview API version")
for contact in client.security_contacts.list(api_version="2023-12-01-preview"):
print(contact)
print("alert_notifications:", contact.alert_notifications)
# Get using default API version (returns expected data)
print("Testing get with default API version")
print(client.security_contacts.get(security_contact_name="default").alert_notifications)
```
**Script Output:**
```
Testing list with default API version
Unable to deserialize to object: type
Testing list with 2023-12-01-preview API version
...
'alert_notifications': None
...
Testing get with default API version
```
**Expected behavior**
The `list()` method should return a fully populated `SecurityContact` object, including a non-null `alert_notifications` field—consistent with what is returned by `get()`.
コントリビューションガイド
調査の方向性
提供された再現スクリプトから始め、デフォルト API バージョンと 2023-12-01-preview API バージョンでの security_contacts.list() と get() のレスポンスを比較します。両方の呼び出しについてデシリアライズと返されるフィールドを追跡します。完了条件は、list() が成功し、get() と整合する値が設定された alert_notifications を返すことです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- azure, python
- 領域
- api, cloud, security
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100