Azure / Azure/azure-sdk-for-python
SecurityCenter().security_contacts list method is not working
- Lingua principale
- Python
- Stelle
- 5.6k
- Fork
- 3.4k
- Merge medio
- 2g 2h
- PR unite (30g)
- 202
Descrizione
- **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()`.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia con lo script di riproduzione fornito e confronta le risposte di security_contacts.list() e get() nelle versioni API predefinita e 2023-12-01-preview. Traccia la deserializzazione e i campi restituiti per entrambe le chiamate; il lavoro è completato quando list() ha esito positivo e restituisce un valore alert_notifications valorizzato, coerente con get().
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- azure, python
- Ambito
- api, cloud, security
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100