"Warning: Discriminator source is absent or null, use base class ResourceDetails." when serializing SecurityAssessment object
- 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.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @chlahav.
Hi service team, the 'resource_details' of returned assessment don't have property "source".
chlahav doesn't own this anymore. Looking for alternative contact person.
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)
@AddySanto Following up to see if there is any update on this issue? - Thank you
Hi @flobeier. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.
Hi @flobeier, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.
/unresolve
Hi nadavu, only the original author of the issue can ask that it be unresolved. Please open a new issue with your scenario and details if you would like to discuss this topic with the team.
/unresolve
@BigCat20196 Please help take a look
similar issue: https://github.com/Azure/azure-sdk-for-python/issues/24815
@BigCat20196 @RAY-316 @msyyc do you have a solution?
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.
Hi @flobeier. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.
Hi @flobeier, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.
/unresolve still not fixed
@flobeier this is a restful API issue rather than as SDK issue. We will close the issue and please use https://github.com/Azure/azure-rest-api-specs/issues/19530 to track the problem.