-
Notifications
You must be signed in to change notification settings - Fork 56
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
Exception: string index out of range when fetching site lists with expand:fields #940
Comments
After several tests, the last configuration that works is the following:
with microsoft-kiota-serialization-json==1.2.0 pinned to 1.2.0 |
Hello @nicolas-lurkin-b12 thanks for using the SDK and for raising this. This looks like an issue we have been experiencing with our JSON serialization: |
Hello @shemogumbe |
I encountered possibly the same issue here. Main Logic async def list_outlook_events(self, start_date: datetime, end_date: datetime):
"""
Lists events created or participated in by the user between start_date and end_date.
Ref: https://learn.microsoft.com/en-us/graph/api/event-get?view=graph-rest-1.0
"""
events = []
request_configuration = RequestConfiguration()
request_configuration.headers.add("Prefer", 'outlook.timezone="Asia/Taipei"')
# Instead of RequestConfiguration, manually set headers in the query
result = await self.graph_client.me.events.get(
request_configuration=request_configuration
)
old_event_count = 0
stop_processing = False
while True:
for event in result.value:
try:
# transformation logic
except Exception as e:
print(f"Error processing event: {e}")
traceback.print_exc()
pyperclip.copy(str(event))
sys.exit(0)
if stop_processing:
break
# Handle pagination if there are more events to retrieve
if result.odata_next_link:
result = await self.graph_client.teams.with_url(result.odata_next_link).get()
.
.
.
return events I have 2 MacBook Pros, that said, MacBook 1 and MacBook 2. The Python script on MacBook 1 works pretty much well and MacBook 2 the same UNTIL TODAY, i.e., MacBook 1 good job and MacBook 2 wanted to play a game with me, a.k.a, failed. Error Message from Traceback Traceback (most recent call last):
File "/Users/shu-jenghsieh/Desktop/Automation Center/journal/jira/metrics/collect_stats.py", line 506, in <module>
asyncio.run(collect_calendar_events(input_year, all=True))
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.13.0_1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 194, in run
return runner.run(main)
~~~~~~~~~~^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.13.0_1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.13.0_1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 721, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "/Users/shu-jenghsieh/Desktop/Automation Center/journal/jira/metrics/collect_stats.py", line 477, in collect_calendar_events
events = await lister.list_outlook_events(start_date_taipei, end_date_taipei)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/shu-jenghsieh/Desktop/Automation Center/journal/jira/metrics/teams/list_outlook_events.py", line 546, in list_outlook_events
result = await self.graph_client.teams.with_url(result.odata_next_link).get()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.13/site-packages/msgraph/generated/teams/teams_request_builder.py", line 69, in get
return await self.request_adapter.send_async(request_info, TeamCollectionResponse, error_mapping)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.13/site-packages/kiota_http/httpx_request_adapter.py", line 196, in send_async
value = root_node.get_object_value(parsable_factory)
File "/opt/homebrew/lib/python3.13/site-packages/kiota_serialization_json/json_parse_node.py", line 222, in get_object_value
self._assign_field_values(result)
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
File "/opt/homebrew/lib/python3.13/site-packages/kiota_serialization_json/json_parse_node.py", line 291, in _assign_field_values
field_deserializer(JsonParseNode(field_value))
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.13/site-packages/msgraph/generated/models/team_collection_response.py", line 40, in <lambda>
"value": lambda n : setattr(self, 'value', n.get_collection_of_object_values(Team)),
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/opt/homebrew/lib/python3.13/site-packages/kiota_serialization_json/json_parse_node.py", line 170, in get_collection_of_object_values
return list(
map(
...<2 lines>...
)
)
File "/opt/homebrew/lib/python3.13/site-packages/kiota_serialization_json/json_parse_node.py", line 172, in <lambda>
lambda x: self._create_new_node(x).get_object_value(factory), # type: ignore
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "/opt/homebrew/lib/python3.13/site-packages/kiota_serialization_json/json_parse_node.py", line 222, in get_object_value
self._assign_field_values(result)
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
File "/opt/homebrew/lib/python3.13/site-packages/kiota_serialization_json/json_parse_node.py", line 293, in _assign_field_values
item_additional_data[field_name] = self.try_get_anything(field_value)
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.13/site-packages/kiota_serialization_json/json_parse_node.py", line 316, in try_get_anything
datetime_obj = pendulum.parse(value)
File "/opt/homebrew/lib/python3.13/site-packages/pendulum/parser.py", line 30, in parse
return _parse(text, **options)
File "/opt/homebrew/lib/python3.13/site-packages/pendulum/parser.py", line 43, in _parse
parsed = base_parse(text, **options)
File "/opt/homebrew/lib/python3.13/site-packages/pendulum/parsing/__init__.py", line 78, in parse
return _normalize(_parse(text, **_options), **_options)
~~~~~~^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.13/site-packages/pendulum/parsing/__init__.py", line 116, in _parse
return _parse_iso8601_interval(text)
File "/opt/homebrew/lib/python3.13/site-packages/pendulum/parsing/__init__.py", line 221, in _parse_iso8601_interval
elif last[0] == "P":
~~~~^^^
IndexError: string index out of range In the beginning, I tweaked I have tried the following versions for
And all led me to the same error message. Machine Info ProductName: macOS
ProductVersion: 14.6.1
BuildVersion: 23G93 Python Version Python 3.13.0 It's installed by Hopefully, my experience can help more developers. |
I'm experiencing the same problem with my Airflow DAG that connects to OneDrive file with Graph SDK. What is confusing in my case is that I have multiple similar DAGs connecting to OneDrive, but only one of them has this error. Our setup:
Python version: On Windows: |
Describe the bug
I am trying to fetch the list of lists for a given site, with an expand on the fields.
This crashes during deserialisation with a "string index out of range".
The full stack trace is the following
The field that is being deserialised is 'WorkPhone' with a value of '/'. That is clearly not a date even though it is trying to decode it as a date.
Expected behavior
I expect to retrieve the decoded object
How to reproduce
This obviously triggers the issue only when the data coming from the request contains the mentioned field with the specific value.
SDK Version
1.11.0
Latest version known to work for scenario above?
None
Known Workarounds
No response
Debug output
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: