"Warning: Discriminator source is absent or null, use base class ResourceDetails." when serializing SecurityAssessment object
See original GitHub issue- Package Name: azure-mgmt-security
- Package Version: 0.4.1
- Operating System: Azure Function
- Python Version: 3.8.2
Describe the bug
Warnings are displayed when the Azure Function runs:
[Warning] Discriminator source is absent or null, use base class ResourceDetails.
To Reproduce Steps to reproduce the behavior:
- Use the following code in an Azure Function:
# Create a generator with EventData objects containing "Unhealthy" security
# assessments
def data_generator():
# Create Subscription Client and retrieve list of all subscriptions
ad_credentials = MSIAuthentication()
client = SubscriptionClient(ad_credentials)
subscriptions = client.subscriptions.list()
# Get security assessments for each subscription and yield the assessments
# with a status of "Unhealthy" as JSON objects
for subscription in subscriptions:
try:
client = SecurityCenter(
credentials=ad_credentials,
subscription_id=subscription.subscription_id,
asc_location="westeurope"
)
assessments = client.assessments.list(scope=subscription.id)
for assessment in assessments:
if assessment.status.code == "Unhealthy":
yield EventData(json.dumps(assessment.as_dict()))
except Exception as e:
logging.error(f"Can't get security assessments for subscription \
{subscription.subscription_id}. {e}")
Expected behavior Warning should be applicable. I’m not sure if that’s the case here. If I am doing something wrong I’d be glad if someone could point it out for me.
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (4 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey,
I’m running into the exact same issue. It looks like it only happens when you access the status object of an assessment. Code snippet below
for assessment in client.assessments.list(scope=sub_id): print(assessment.status.code)
Hi @nadavu the issue is addressed and it is swagger issue. Once https://github.com/Azure/azure-rest-api-specs/issues/19530 is solved, SDK could release new version to fix it.