strptime() argument 1 must be str, not None

Open
#5 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
databases

Research direction

Start in radicale_storage_by_index/init.py at get_all_filtered, especially the request handling around line 196 and the datetime parsing shown in the traceback. Reproduce the calendar-query request with a start but no end, then verify that the request completes without the None strptime error and that bounded ranges still work.

Written by the indexing model from the issue text.

Description

In case a request is done with the following content:

<?xml version="1.0"?>
<C:calendar-query xmlns="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
  <prop>
    <getetag />
  </prop>
  <C:filter>
    <C:comp-filter name="VCALENDAR">
      <C:comp-filter name="VEVENT">
        <C:time-range start="20180823T112032Z" />
      </C:comp-filter>
    </C:comp-filter>
  </C:filter>
</C:calendar-query>

There is an exception:

Traceback (most recent call last):
  File "/srv/radicale/env/lib/python3.5/site-packages/radicale/__init__.py", line 332, in __call__
    status, headers, answers = self._handle_request(environ)
  File "/srv/radicale/env/lib/python3.5/site-packages/radicale/__init__.py", line 505, in _handle_request
    environ, base_prefix, path, user)
  File "/srv/radicale/env/lib/python3.5/site-packages/radicale/__init__.py", line 982, in do_REPORT
    base_prefix, path, xml_content, collection)
  File "/srv/radicale/env/lib/python3.5/site-packages/radicale/xmlutils.py", line 1267, in report
    multistatus):
  File "/srv/radicale/env/lib/python3.5/site-packages/radicale/xmlutils.py", line 1241, in retrieve_items
    yield from collection.get_all_filtered(filters)
  File "/srv/radicale/env/src/radicale-storage-by-index/radicale_storage_by_index/__init__.py", line 216, in get_all_filtered
    datetime.strptime(request['dtend'], "%Y%m%dT%H%M%SZ"))
TypeError: strptime() argument 1 must be str, not None

This is caused by line 196 which adds dtend to the request always in case there is a time range in the content.
But in the example request there is only a start and no end..

Easy fix is to ONLY add dtend to request if filter_.get("end") is not None

Dominant language
Python
Stars
1
Forks
3
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from Kozea/RadicaleStorageByIndex

All issues in Kozea/RadicaleStorageByIndex

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.