Graph API response field format mismatch with SDK object field format
まだ誰も着手していません。
評価
調査の方向性
JsonParseNode、ConditionalAccessPolicy、および transferMethods の値の例で不一致を再現し、その後 GraphServiceClient のリクエストパスと比較します。API がカンマ区切りの文字列を返す場合に conditions.authenticationFlows.transfer_methods がどのようにパースされるかを追跡します。完了条件は、SDK が返されたメソッドを、想定される ConditionalAccessTransferMethods enum のリストとして公開することです。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
The field in question is for Conditional Access Policies (https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies): conditions.authenticationFlows.transferMethods. When specified in a policy, the graph API returns this field as a comma-separated string, e.g. "transferMethods": "deviceCodeFlow,authenticationTransfer". When parsed by this SDK in this format, ConditionalAccessPolicy.conditions.authentication_flows.transfer_methods get's incorrectly set to an empty array ([]).
The SDK expects the value of this field to be an array, rather than a comma-separated string. The following code demonstrates the incorrect and desired behaviors:
from kiota_serialization_json.json_parse_node import JsonParseNode
from msgraph_beta.generated.models.conditional_access_policy import ConditionalAccessPolicy
json_data = {
"displayName": "Test Device Code & Authentication Transfers",
"state": "enabled",
"conditions": {
...
"authenticationFlows": {
"transferMethods": "deviceCodeFlow,authenticationTransfer"
}
},
...
}
msgraph_sdk_obj = JsonParseNode(json_data).get_object_value(ConditionalAccessPolicy())
# msgraph_sdk_obj.conditions.authentication_flows.transfer_methods == []
fixed_json_data = {
...
"conditions": {
...
"authenticationFlows": {
"transferMethods": ["deviceCodeFlow", "authenticationTransfer"]
}
},
...
}
fixed_msgraph_sdk_obj = JsonParseNode(fixed_json_data).get_object_value(ConditionalAccessPolicy())
# fixed_msgraph_sdk_obj.conditions.authentication_flows.transfer_methods == [
# <ConditionalAccessTransferMethods.DeviceCodeFlow: 'deviceCodeFlow'>,
# <ConditionalAccessTransferMethods.AuthenticationTransfer: 'authenticationTransfer'>
# ]
The following screenshot shows that the API returns it in the comma-separated string format:
So the issue still exists when using the msgraph-sdk API request instead of the JSON parser. e.g.
from msgraph_beta.graph_service_client import GraphServiceClient
GraphServiceClient(...).identity.conditional_access.policies.by_conditional_access_policy_id('conditionalAccessPolicy-id').get()
And in the Entra UI it looks like the following:
I don't know whether this bug should be fixed in this SDK or in the Graph API itself.
Expected behavior
msgraph_sdk_cap_obj: ConditionalAccessPolicy
msgraph_sdk_cap_obj.conditions.authentication_flows.transfer_methods ==
[
<ConditionalAccessTransferMethods.DeviceCodeFlow: 'deviceCodeFlow'>,
<ConditionalAccessTransferMethods.AuthenticationTransfer: 'authenticationTransfer'>
]
# not []
How to reproduce
The code above can be used to reproduce.
SDK Version
1.31.0
Latest version known to work for scenario above?
No response
Known Workarounds
No response
Debug output
Click to expand for a full example JSON of a policy
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#identity/conditionalAccess/policies/$entity",
"@microsoft.graph.tips": "Use $select to choose only the properties your app needs, as this can lead to performance improvements. For example: GET identity/conditionalAccess/policies('<guid>')?$select=conditions,createdDateTime",
"templateId": null,
"displayName": "Test Device Code & Authentication Transfers",
"state": "enabledForReportingButNotEnforced",
"sessionControls": null,
"conditions": {
"userRiskLevels": [],
"signInRiskLevels": [],
"clientAppTypes": ["all"],
"servicePrincipalRiskLevels": [],
"insiderRiskLevels": null,
"platforms": null,
"locations": null,
"devices": null,
"clientApplications": null,
"applications": {
"includeApplications": ["None"],
"excludeApplications": [],
"includeUserActions": [],
"includeAuthenticationContextClassReferences": [],
"applicationFilter": null
},
"users": {
"includeUsers": ["All"],
"excludeUsers": [],
"includeGroups": [],
"excludeGroups": [],
"includeRoles": [],
"excludeRoles": [],
"includeGuestsOrExternalUsers": null,
"excludeGuestsOrExternalUsers": null
},
"authenticationFlows": {
"transferMethods": "deviceCodeFlow,authenticationTransfer"
}
},
"grantControls": {
"operator": "OR",
"builtInControls": ["block"],
"customAuthenticationFactors": [],
"termsOfUse": [],
"authenticationStrength@odata.context": "https://graph.microsoft.com/v1.0/$metadata#identity/conditionalAccess/policies('e7a127d6-b745-47da-814e-f909748cff0d')/grantControls/authenticationStrength/$entity",
"authenticationStrength": null
}
}
Configuration
macOS, python 3.12
Other information
No response
- 主要言語
- Python
- スター
- 44
- フォーク
- 16
- 平均マージ
- 20時間 39分
- マージ済み PR(30日)
- 3
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoftgraph/msgraph-beta-sdk-python のほかの issue
-
enhancement
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
-
status:waiting-for-triage type:bug
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
-
type:bug type:investigation
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
microsoftgraph/msgraph-beta-sdk-python#1033 · リアクション 1 件 ·
-
status:waiting-for-triage type:bug
難易度 3/5 1〜2日 初心者へのやさしさ 42/100
microsoftgraph/msgraph-beta-sdk-python#1006 · コメント 1 件 ·
-
status:waiting-for-triage type:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 48/100
microsoftgraph/msgraph-beta-sdk-python#987 · コメント 2 件 ·
microsoftgraph/msgraph-beta-sdk-python の issue をすべて見る
似ている issue
-
link-check link-check:sphinx-theme
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
OpenHands/extensions#626 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
CSCfi/sd-search-api#39 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100