Skip to content

TypeError in today(): '<' not supported between NoneType and str during sort #146

@donaldpiret

Description

@donaldpiret

Bug Description

things.today() raises a TypeError when there are overdue tasks (with no start date) mixed with regular today tasks.

TypeError: '<' not supported between instances of 'NoneType' and 'str'

Root Cause

In things/api.py, line 527:

result.sort(key=lambda task: (task["today_index"], task["start_date"]))

The today() function merges three task lists:

  1. regular_today_tasks — have a start_date
  2. unconfirmed_scheduled_tasks — have a start_date
  3. unconfirmed_overdue_tasks — queried with start_date=False, so start_date is None

When Python tries to sort tuples containing a mix of None and str values, it raises TypeError. This happens whenever you have at least one overdue task (no start date) mixed with regular today tasks.

Suggested Fix

Use None-safe sort keys:

result.sort(key=lambda task: (task["today_index"] or 0, task["start_date"] or ""))

Other Affected Sorts

There are two other similar sorts in the same file that could also fail with None values:

  • logbook(): result.sort(key=lambda task: task["stop_date"], reverse=True) — could fail if stop_date is None
  • deadlines(): result.sort(key=lambda task: task["deadline"]) — less likely but still possible

Environment

  • things.py v1.0.0
  • Python 3.14
  • macOS
  • Triggered via things-mcp v0.7.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions