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

Calendar Update Failed #193

Open
JayWll opened this issue Nov 21, 2024 · 7 comments
Open

Calendar Update Failed #193

JayWll opened this issue Nov 21, 2024 · 7 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@JayWll
Copy link

JayWll commented Nov 21, 2024

Home Assistant Setup
Please indicate your version of HA and how it is installed.

Version: 2024.11.2

Installation Type (put an X between the square brackets for your HA):
[x] Home Assistant OS
[] Home Assistant Supervised
[] Home Assistant Container
[] Home Assistant Core

Hardware platform:
[x] ARM
[] x86-64

Describe the bug
One of my calendars that had previously been working has been consistently failing over the past few days. No events are visible in the calendar. Other calendars managed through ics_calendar are not experiencing any issue. I assime therefore this must be related to some content/event on the calendar itself, but I can't figure out what that could be. The error from the home assistant logs is below, although I've truncated both the ValueError lines as they're each several thousand characters long.

Validating the ical file through https://icalendar.org/validator.html results in no errors found.

I'm using ics_calendar version 5.0.4 installed through HACS.

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/icalendar/parser.py", line 326, in parts
    validate_token(name)
  File "/usr/local/lib/python3.12/site-packages/icalendar/parser.py", line 115, in validate_token
    raise ValueError(name)
ValueError: 䕂䥇㩎䍖䱁久䅄൒嘊剅䥓乏㈺〮਍剐䑏䑉樺祡汷⽬捩污਍䅎䕍场

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 944, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1304, in async_device_update
    await hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ics_calendar/calendar.py", line 209, in update
    self.data.update()
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 184, in wrapper
    result = method(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ics_calendar/calendar.py", line 329, in update
    self.parser.set_content(self._calendar_data.get())
  File "/config/custom_components/ics_calendar/parsers/parser_rie.py", line 33, in set_content
    self._calendar = Calendar.from_ical(content)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/icalendar/cal.py", line 354, in from_ical
    name, params, vals = line.parts()
                         ^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/icalendar/parser.py", line 340, in parts
    raise ValueError(
ValueError: Content line could not be parsed into parts: '䕂䥇㩎䍖䱁久䅄൒嘊剅
@JayWll
Copy link
Author

JayWll commented Nov 25, 2024

After much exploration, I managed to track the problem down to the problematic calendar event, and I eventually figured out that its description included the Unicode character for a non breaking space \u00a0.

I was able to replace it with a regular space and all is now well. I'm not sure what ics_calendar's expected behaviour should be.

@franc6
Copy link
Owner

franc6 commented Nov 26, 2024

My expectation is that it would work. :)

I might be able to work around it, but when I have the chance, I’ll see if I can reproduce it with something small and submit a bug report to the parser. As long as it was UTF-8 encoded correctly, it should be allowed, IMO.

@CAP-Team
Copy link

I also get a lot of calendar update fails.

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/tatsu/contexts.py", line 609, in _call
    result = self._recursive_call(ruleinfo)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tatsu/contexts.py", line 640, in _recursive_call
    return self._invoke_rule(ruleinfo, key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tatsu/contexts.py", line 700, in _invoke_rule
    self._pop_ast()
  File "/usr/local/lib/python3.12/site-packages/tatsu/contexts.py", line 345, in _pop_ast
    self.tokenizer.goto(self.state.pos)
                        ^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tatsu/contexts.py", line 298, in state
    return self._statestack[-1]
           ~~~~~~~~~~~~~~~~^^^^
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/tatsu/contexts.py", line 688, in _invoke_rule
    ruleinfo.impl(self)
  File "/usr/local/lib/python3.12/site-packages/ics/grammar/contentline.py", line 85, in _start_
    self._contentline_()
  File "/usr/local/lib/python3.12/site-packages/tatsu/contexts.py", line 77, in wrapper
    return self._call(ruleinfo)
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tatsu/contexts.py", line 627, in _call
    self._rule_stack.pop()
IndexError: pop from empty list

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/tatsu/contexts.py", line 609, in _call
    result = self._recursive_call(ruleinfo)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tatsu/contexts.py", line 640, in _recursive_call
    return self._invoke_rule(ruleinfo, key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tatsu/contexts.py", line 700, in _invoke_rule
    self._pop_ast()
  File "/usr/local/lib/python3.12/site-packages/tatsu/contexts.py", line 344, in _pop_ast
    self._statestack.pop()
IndexError: pop from empty list

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 944, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1304, in async_device_update
    await hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ics_calendar/calendar.py", line 209, in update
    self.data.update()
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 184, in wrapper
    result = method(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ics_calendar/calendar.py", line 329, in update
    self.parser.set_content(self._calendar_data.get())
  File "/config/custom_components/ics_calendar/parsers/parser_ics.py", line 33, in set_content
    self._calendar = Calendar(re.sub(self._re_method, "", content))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ics/icalendar.py", line 64, in __init__
    containers = calendar_string_to_containers(imports)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ics/grammar/parse.py", line 227, in calendar_string_to_containers
    return string_to_container(string)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ics/grammar/parse.py", line 204, in string_to_container
    return lines_to_container(txt.split("\n"), linewise)  # linewise
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ics/grammar/parse.py", line 197, in lines_to_container
    return parse(tokenize_line(unfold_lines(lines, with_linenr=True)))  # linewise
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ics/grammar/parse.py", line 189, in parse
    res.append(Container.parse(line.value, tokenized_lines))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ics/grammar/parse.py", line 130, in parse
    for line in tokenized_lines:
  File "/usr/local/lib/python3.12/site-packages/ics/grammar/parse.py", line 180, in tokenize_line
    yield ContentLine.parse(line[1], line[0])
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ics/grammar/parse.py", line 82, in parse
    ast = GRAMMAR.parse(line)
          ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tatsu/contexts.py", line 241, in parse
    return rule()
           ^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tatsu/contexts.py", line 77, in wrapper
    return self._call(ruleinfo)
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tatsu/contexts.py", line 627, in _call
    self._rule_stack.pop()
IndexError: pop from empty list

@franc6 franc6 self-assigned this Dec 13, 2024
@franc6
Copy link
Owner

franc6 commented Dec 14, 2024

@JayWll I can't reproduce this, using either the current version of icalendar, or the version that was used by v5.0.4. Can you provide more detail on where exactly the non-breaking space was? Looking at the code, the error is confusing for that to be a problem.

@CAP-Team Can you post the actual ics file, with any personal info redacted? I don't think you're seeing the same problem, but I don't have enough info to determine what might be wrong.

Thanks!

@franc6 franc6 added the question Further information is requested label Dec 14, 2024
@CAP-Team
Copy link

Current errors. Funny thing is I only get errors on calendars that are shared with me, I don't see errors for my own calendar
calendar.zip

Logger: homeassistant.helpers.entity
Bron: helpers/entity.py:960
Eerst voorgekomen: 13:03:41 (67 gebeurtenissen)
Laatst gelogd: 22:57:41

Update for calendar.wife fails
Update for calendar.son1 fails
Update for calendar.son2 fails
Update for calendar.kids fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/tatsu/contexts.py", line 688, in _invoke_rule
    ruleinfo.impl(self)
    ~~~~~~~~~~~~~^^^^^^
  File "/usr/local/lib/python3.13/site-packages/ics/grammar/contentline.py", line 104, in _contentline_
    self._ALPHADIGIT_MINUS_PLUS_()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/tatsu/contexts.py", line 77, in wrapper
    return self._call(ruleinfo)
           ~~~~~~~~~~^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/tatsu/contexts.py", line 614, in _call
    self._append_cst(node)
    ~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/local/lib/python3.13/site-packages/tatsu/contexts.py", line 383, in _append_cst
    previous = self.cst
               ^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/tatsu/contexts.py", line 358, in cst
    return self.state.cst
           ^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/tatsu/contexts.py", line 298, in state
    return self._statestack[-1]
           ~~~~~~~~~~~~~~~~^^^^
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/tatsu/contexts.py", line 609, in _call
    result = self._recursive_call(ruleinfo)
  File "/usr/local/lib/python3.13/site-packages/tatsu/contexts.py", line 640, in _recursive_call
    return self._invoke_rule(ruleinfo, key)
           ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/tatsu/contexts.py", line 700, in _invoke_rule
    self._pop_ast()
    ~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/tatsu/contexts.py", line 344, in _pop_ast
    self._statestack.pop()
    ~~~~~~~~~~~~~~~~~~~~^^
IndexError: pop from empty list

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/tatsu/contexts.py", line 688, in _invoke_rule
    ruleinfo.impl(self)
    ~~~~~~~~~~~~~^^^^^^
  File "/usr/local/lib/python3.13/site-packages/ics/grammar/contentline.py", line 85, in _start_
    self._contentline_()
    ~~~~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/tatsu/contexts.py", line 77, in wrapper
    return self._call(ruleinfo)
           ~~~~~~~~~~^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/tatsu/contexts.py", line 627, in _call
    self._rule_stack.pop()
    ~~~~~~~~~~~~~~~~~~~~^^
IndexError: pop from empty list

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/tatsu/contexts.py", line 609, in _call
    result = self._recursive_call(ruleinfo)
  File "/usr/local/lib/python3.13/site-packages/tatsu/contexts.py", line 640, in _recursive_call
    return self._invoke_rule(ruleinfo, key)
           ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/tatsu/contexts.py", line 700, in _invoke_rule
    self._pop_ast()
    ~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/tatsu/contexts.py", line 344, in _pop_ast
    self._statestack.pop()
    ~~~~~~~~~~~~~~~~~~~~^^
IndexError: pop from empty list

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 960, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1320, in async_device_update
    await hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/ics_calendar/calendar.py", line 209, in update
    self.data.update()
    ~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 184, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/ics_calendar/calendar.py", line 329, in update
    self.parser.set_content(self._calendar_data.get())
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ics_calendar/parsers/parser_ics.py", line 33, in set_content
    self._calendar = Calendar(re.sub(self._re_method, "", content))
                     ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/ics/icalendar.py", line 64, in __init__
    containers = calendar_string_to_containers(imports)
  File "/usr/local/lib/python3.13/site-packages/ics/grammar/parse.py", line 227, in calendar_string_to_containers
    return string_to_container(string)
  File "/usr/local/lib/python3.13/site-packages/ics/grammar/parse.py", line 204, in string_to_container
    return lines_to_container(txt.split("\n"), linewise)  # linewise
  File "/usr/local/lib/python3.13/site-packages/ics/grammar/parse.py", line 197, in lines_to_container
    return parse(tokenize_line(unfold_lines(lines, with_linenr=True)))  # linewise
  File "/usr/local/lib/python3.13/site-packages/ics/grammar/parse.py", line 189, in parse
    res.append(Container.parse(line.value, tokenized_lines))
               ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/ics/grammar/parse.py", line 132, in parse
    items.append(Container.parse(line.value, tokenized_lines))
                 ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/ics/grammar/parse.py", line 130, in parse
    for line in tokenized_lines:
                ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/ics/grammar/parse.py", line 180, in tokenize_line
    yield ContentLine.parse(line[1], line[0])
          ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/ics/grammar/parse.py", line 82, in parse
    ast = GRAMMAR.parse(line)
  File "/usr/local/lib/python3.13/site-packages/tatsu/contexts.py", line 241, in parse
    return rule()
  File "/usr/local/lib/python3.13/site-packages/tatsu/contexts.py", line 77, in wrapper
    return self._call(ruleinfo)
           ~~~~~~~~~~^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/tatsu/contexts.py", line 627, in _call
    self._rule_stack.pop()
    ~~~~~~~~~~~~~~~~~~~~^^
IndexError: pop from empty list

@franc6 franc6 added the bug Something isn't working label Dec 18, 2024
@franc6
Copy link
Owner

franc6 commented Jan 20, 2025

@CAP-Team I can't reproduce the problem using your ics file, with either the ics parser (what it looks like you're using, from the error message), or with recurring_ical_events. Can you configure the failing calendars to use the default rie parser instead of ics?

@CAP-Team
Copy link

I must say since the last updates I haven't had any errors retrieving the calendars.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants