microsoftgraph / microsoftgraph/msgraph-beta-sdk-python

conditionalAccessConditionSet resource type desterilizes dropping agentIdRiskLevels

Open
#1,033 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

type:bug type:investigation
Dominant language
Python
Stars
44
Forks
16
Avg merge
20h 39m
Merged PRs (30d)
3

Description

Describe the bug

The SDK model in conditional_access_condition_set.py correctly declares this as a collection:

"agentIdRiskLevels": lambda n: setattr(
    self, 'agent_id_risk_levels',
    n.get_collection_of_enum_values(ConditionalAccessAgentIdRiskLevels)
)

However, kiota-serialization-json's get_collection_of_enum_values only handles list inputs:

def get_collection_of_enum_values(self, enum_class: K) -> Optional[list[K]]:
    if isinstance(self._json_node, list):  # scalar string fails this check
        return list(map(
            lambda x: self._create_new_node(x).get_enum_value(enum_class),
            self._json_node
        ))
    return []  # ← value silently dropped

When the API returns "high" (a string, not a list), isinstance(self._json_node, list) is False, so the method returns [] and the actual value is silently lost.

Expected behavior

policy.conditions.agent_id_risk_levels should return [ConditionalAccessAgentIdRiskLevels.High].

The issue could be:

API-side: The API should return ["high"] (array) per the documentation, which describes this as a collection
Kiota-side: get_collection_of_enum_values should handle a scalar gracefully by wrapping it in a list (this may warrant a separate issue on microsoft/kiota-serialization-json-python)

How to reproduce
  1. Have a Conditional Access policy with an agent ID risk level condition set (e.g. high)

  2. Fetch policies via the Beta SDK:
    result = await graph_client.identity.conditional_access.policies.get()

  3. Inspect policy.conditions.agent_id_risk_levels — it will be [] instead of [ConditionalAccessAgentIdRiskLevels.High]

SDK Version

1.57

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output
Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with conditional_access_condition_set.py and the get_collection_of_enum_values implementation in kiota-serialization-json; reproduce the scalar "high" response through the documented policy fetch. Determine whether the API or serializer is responsible, then verify that agent_id_risk_levels preserves the value as [ConditionalAccessAgentIdRiskLevels.High].

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.