Azure / Azure/azure-sdk-for-python

SecurityCenter().security_contacts list method is not working

Open
#41,591 2 comments 1 reaction 0 assignees View on GitHub
customer-reported Mgmt needs-team-attention question Security Service Attention
Dominant language
Python
Stars
5.6k
Forks
3.4k
Avg merge
1d 21h
Merged PRs (30d)
193

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.