Invalid key: UserExtend for enum AccessPackageRequestType
Describe the bug
If my program is attempting to get all access package assignment requests, and comes across a request that has Request Type "UserExtend" it will throw and exception with the error stated in the title.
This type has been documented as a supported type in AccessPackageAssignmentRequest, but is not implemented in the AccessPackageRequestType.
Expected behavior
When making the call to retrieve all access package requests, it should return all requests - of all types, and not throw an exception.
How to reproduce
Requirement: Have an access package request of type "UserExtend" and an initialized GraphServiceClient.
then execute the code:
access_package_requests= await graph_client.identity_governance.entitlement_management.assignment_requests.get()
SDK Version
1.5.3
Latest version known to work for scenario above?
No response
Known Workarounds
None. Enum type is not implemented.
Debug output
No response
Configuration
No response
Other information
No response
Hello @MultimedYam Thanks for using the SDK and for raising this.
Running the query against the graph gives me a AccessPackageAssignmentRequestCollectionResponse
In your case you say it throws an error in Enum serialization, Could you kindly provide more details to help reproduce.
Any snippets, content of your setup for the identity governence entitlement?
I ran:
async def get_user_access_package():
try:
access_package_requests = await user_client.identity_governance.entitlement_management.assignment_requests.get(
)
print(f"Access Package Requests: {access_package_requests.value}")
except APIError as api_error:
print(f"api error {api_error}")
Thanks for looking into this @shemogumbe The configuration for our Identity Governance access packages is the basic implementation. These were made on the Azure portal.
My snippet of code I use to get the assignment requests expands on some supported fields:
async def getAllAccessPackageRequests(self):
access_package_request_list = []
query_params = AssignmentRequestsRequestBuilder.AssignmentRequestsRequestBuilderGetQueryParameters(
expand= ['accessPackage($select=id,displayName)', 'assignment($expand=target($select=id,displayname,email))','requestor']
)
request_config = AssignmentRequestsRequestBuilder.AssignmentRequestsRequestBuilderGetRequestConfiguration(
query_parameters=query_params
)
accessPackageRequests = await self.app_client.identity_governance.entitlement_management.assignment_requests.get(request_config)
and results in
Exception has occurred: Exception
Invalid key: UserExtend for enum <enum 'AccessPackageRequestType'>.
KeyError: 'UserExtend'
During handling of the above exception, another exception occurred:
File "C:\[path]\graph.py", line 130, in getAllAccessPackageRequests
accessPackageRequests = await self.app_client.identity_governance.entitlement_management.assignment_requests.get(request_config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\[path]\main.py", line 48, in extractAccessPackageRequestsAndApprovals
access_package_requests = await graph.getAllAccessPackageRequests()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\[path]\main.py", line 57, in main
await extractAccessPackageRequestsAndApprovals(graph)
File "C:\[path]\main.py", line 59, in <module>
asyncio.run(main())
Exception: Invalid key: UserExtend for enum <enum 'AccessPackageRequestType'>.
I double checked the values returned by running the same msgraph call in Postman:
https://graph.microsoft.com/v1.0/identityGovernance/entitlementManagement/assignmentRequests?$expand=accessPackage($select=id,displayName),assignment($expand=target),requestor
In most cases, this exception is not thrown and I receive the expected AccessPackageAssignmentRequestCollectionResponse as the returned requestType is a supported userAdd or userRemove. However when it comes across a UserExtend this unknown enum key causes the exception in question. This is caused by the fact that this key is not implemented in the AccessPackageRequestType class
I hope this provides more insight.
Noted, Picking this up So far still unable o reproduce it with default setings as:
async def getAllAccessPackageRequests():
query_params = AssignmentRequestsRequestBuilder.AssignmentRequestsRequestBuilderGetQueryParameters(
expand=[
'accessPackage($select=id,displayName)',
'assignment($expand=target($select=id,displayname,email))',
'requestor'
])
request_config = AssignmentRequestsRequestBuilder.AssignmentRequestsRequestBuilderGetRequestConfiguration(
query_parameters=query_params)
access_package_requests = await user_client.identity_governance.entitlement_management.assignment_requests.get(
request_config)
print(f"Access Package Requests: {access_package_requests.value}")
asyncio.run(getAllAccessPackageRequests())
gives me
Access Package Requests: []
Hello @MultimedYam upon investigation, this is an issue on the metadata used to generate the SDK, I have documented and raised this tickt https://github.com/microsoftgraph/msgraph-metadata/issues/661 that once fixed will automatically fix this, Following up with @irvinesunday @petrhollayms for quick resolution