question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"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:

  1. 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:closed
  • Created 3 years ago
  • Comments:16 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
markusbnetcommented, Feb 21, 2021

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)

1reaction
msyyccommented, Jul 5, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found