Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid key: UserExtend for enum AccessPackageRequestType #838

Open
MultimedYam opened this issue Aug 2, 2024 · 4 comments
Open

Invalid key: UserExtend for enum AccessPackageRequestType #838

MultimedYam opened this issue Aug 2, 2024 · 4 comments
Assignees
Labels
dependency:metadata Awaiting fix from core dependency project module type:bug A broken experience

Comments

@MultimedYam
Copy link

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

@MultimedYam MultimedYam added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Aug 2, 2024
@shemogumbe
Copy link
Collaborator

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}")

@shemogumbe shemogumbe added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Aug 6, 2024
@MultimedYam
Copy link
Author

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.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Aug 6, 2024
@shemogumbe
Copy link
Collaborator

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: []

@shemogumbe
Copy link
Collaborator

Hello @MultimedYam upon investigation, this is an issue on the metadata used to generate the SDK, I have documented and raised this tickt microsoftgraph/msgraph-metadata#661 that once fixed will automatically fix this, Following up with @irvinesunday @petrhollayms for quick resolution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependency:metadata Awaiting fix from core dependency project module type:bug A broken experience
Projects
None yet
Development

No branches or pull requests

2 participants