directory_object.by_directory_object_id: 'str' object has no attribute 'get'
还没有人认领这个 Issue。
评估
调研方向
使用 Python 3.10.12、msgraph-core==1.0.0a4 和 msgraph-sdk==1.0.0a12 重现该调用。从 generated/directory_objects/item/directory_object_item_request_builder.py 开始,跟踪 response 经过 kiota_http/httpx_request_adapter.py、kiota_serialization_json/json_parse_node.py 和 generated/models/directory_object.py 的流程。完成的标准是 directory-object 请求不再引发所报告的 AttributeError,并且其 response 可以被返回。
由索引模型根据 Issue 内容生成。
描述
Python 3.10.12 and msgraph-core==1.0.0a4 and msgraph-sdk==1.0.0a12, on Ubuntu 20 LTS.
I'm trying to replace a working azure-graphrbac function with the replacement msgraph version - it's to find a displayName for Azure IAM Role Assignments. From the few examples for app-only usage, I thought this was what I needed, but I get an error from deep inside the library that str object has no attribute get.
From what I could tell the parameter to by_directory_object() is supposed to be a string. The self.app_client is the Graph object from this tutorial: https://learn.microsoft.com/en-us/graph/tutorials/python-app-only?tabs=aad&tutorial-step=5 which does successfully list users, but not call my function.
async def get_directoryobject_by_id(self, object_id: str) -> DirectoryObject | None:
"""Given an AD ID from a Role Assignment, figure out what it is"""
try:
thing = await self.app_client.directory_objects.by_directory_object_id(object_id).get()
if thing:
print(thing)
return thing
except APIError as e:
print(e.error.message)
return None
Where am I going wrong? Having the library code be generated and the README just point to the REST API is quite frustrating.
Full stacktrace follows:
Traceback (most recent call last):
File "/home/howardwork/Work/collector/example.py", line 135, in <module>
asyncio.run(main())
File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/home/howardwork/Work/collector/example.py", line 101, in main
await make_graph_call(graph)
File "/home/howardwork/Work/collector/example.py", line 131, in make_graph_call
await graph.get_directoryobject_by_id("05eb8c5a-a278-408e-a2b5-739f56c00888")
File "/home/howardwork/Work/collector/example.py", line 59, in get_directoryobject_by_id
thing = await self.app_client.directory_objects.by_directory_object_id(object_id).get()
File "/home/howardwork/Work/collector/venv/lib/python3.10/site-packages/msgraph/generated/directory_objects/item/directory_object_item_request_builder.py", line 82, in get
return await self.request_adapter.send_async(request_info, directory_object.DirectoryObject, error_mapping)
File "/home/howardwork/Work/collector/venv/lib/python3.10/site-packages/kiota_http/httpx_request_adapter.py", line 123, in send_async
result = root_node.get_object_value(model_type)
File "/home/howardwork/Work/collector/venv/lib/python3.10/site-packages/kiota_serialization_json/json_parse_node.py", line 224, in get_object_value
result = factory.create_from_discriminator_value(self)
File "/home/howardwork/Work/collector/venv/lib/python3.10/site-packages/msgraph/generated/models/directory_object.py", line 32, in create_from_discriminator_value
mapping_value_node = parse_node.get_child_node("@odata.type")
File "/home/howardwork/Work/collector/venv/lib/python3.10/site-packages/kiota_serialization_json/json_parse_node.py", line 55, in get_child_node
if self._json_node and self._json_node.get(identifier):
AttributeError: 'str' object has no attribute 'get'
- 主要语言
- Python
- 星标
- 630
- 派生
- 96
- 平均合并
- 15 小时 20 分钟
- 30 天内合并 PR
- 3
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoftgraph/msgraph-sdk-python 的其他 Issue
-
status:waiting-for-triage type:bug
难度 1/5 1 小时以内 新手友好度 90/100
microsoftgraph/msgraph-sdk-python#1570 ·
-
status:waiting-for-triage type:bug
难度 2/5 1-3 小时 新手友好度 75/100
microsoftgraph/msgraph-sdk-python#1563 ·
-
Needs: Attention :wave: type:bug
难度 2/5 1-3 小时 新手友好度 62/100
microsoftgraph/msgraph-sdk-python#1287 · 2 条评论 · 1 个 reaction ·
-
status:waiting-for-triage
难度 5/5 一周以上 新手友好度 25/100
microsoftgraph/msgraph-sdk-python#1557 ·
-
status:waiting-for-triage type:bug
难度 3/5 1-2 天 新手友好度 55/100
microsoftgraph/msgraph-sdk-python#1556 · 1 条评论 · 1 个 reaction ·
查看 microsoftgraph/msgraph-sdk-python 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 84/100
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 86/100
-
🐛 Bug 🔔 Pending processing
难度 2/5 1-3 小时 新手友好度 84/100
jumpserver/jumpserver#17584 ·