Azure / Azure/azure-sdk-for-python

SecurityCenter().security_contacts list method is not working

Offen
#41,591 2 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
customer-reported Mgmt needs-team-attention question Security Service Attention
Vorherrschende Sprache
Python
Sterne
5.6k
Forks
3.4k
Ø Merge
2 T. 2 Std.
Gemergte PRs (30 T.)
202

Beschreibung

- **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()`.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit dem bereitgestellten Reproduktionsskript und vergleiche die Antworten von security_contacts.list() und get() unter den standardmäßigen und den 2023-12-01-preview API-Versionen. Verfolge die Deserialisierung und die zurückgegebenen Felder für beide Aufrufe; abgeschlossen ist die Aufgabe, wenn list() erfolgreich ist und einen befüllten alert_notifications-Wert zurückgibt, der mit get() übereinstimmt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
azure, python
Bereich
api, cloud, security
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.