Azure / Azure/azure-sdk-for-python
SecurityCenter().security_contacts list method is not working
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 5.6k
- Forks
- 3.4k
- Merge moyen
- 2 j 2 h
- PR mergées (30 j)
- 213
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, "<subscription-id>")
# 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 alert_notifications object>
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().
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par le script de reproduction fourni et comparez les réponses de security_contacts.list() et get() avec les versions d’API par défaut et 2023-12-01-preview. Suivez la désérialisation et les champs renvoyés pour les deux appels ; le travail est terminé lorsque list() réussit et renvoie une valeur alert_notifications renseignée, cohérente avec get().
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- azure, python
- Domaine
- api, cloud, security
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100