# Anki-Connect (new 26.10 rewrite): \[Errno 22\] on Windows for learning cards in filtered decks — breaks getDecks / cardsInfo

**URL:** <https://forums.ankiweb.net/t/anki-connect-new-26-10-rewrite-errno-22-on-windows-for-learning-cards-in-filtered-decks-breaks-getdecks-cardsinfo/71419>\
**Category:** Add-ons\
**Created:** [October 13, 2026, 9:51am UTC](https://forums.ankiweb.net/t/anki-connect-new-26-10-rewrite-errno-22-on-windows-for-learning-cards-in-filtered-decks-breaks-getdecks-cardsinfo/71419 "2026-10-13T09:51:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cpp1660](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@cpp1660](https://forums.ankiweb.net/u/cpp1660)\
**Post date:** [October 13, 2026, 9:51am UTC](https://forums.ankiweb.net/t/anki-connect-new-26-10-rewrite-errno-22-on-windows-for-learning-cards-in-filtered-decks-breaks-getdecks-cardsinfo/71419/1 "2026-10-13T09:51:43Z")

</div>

**Environment**

- Anki 26.08.1 (39e4b0b4), Python 3.13.13, Qt 6.11.0, Windows 11 x64
- Anki-Connect (2055492159) auto-updated on 2026-10-13 to the new JSON-RPC/v1 rewrite (a build from before 26.10.12.2)

**Problem**

Any request that serializes certain cards fails with `[Errno 22] Invalid argument`. In my case the legacy `getDecks` call fails, so a full Logseq → Anki sync (logseq-anki-sync 7.0.6) aborts every time.

**Cause**

In `services.py`, `state_record()` does:

```python
elif card.queue in (1, 4) or (card.queue < 0 and card.type in (1, 3) and card.due > 1000000000):
    due = {'kind': 'timestamp', 'at': timestamp(card.due)}

```

When a learning card (`queue = 1`) is inside a **filtered deck** , Anki stores a negative ordering value in `due` (e.g. `-99921`, i.e. `-100000 + position`), not an epoch timestamp. `timestamp()` in `protocol.py` calls `datetime.fromtimestamp(seconds, timezone.utc)`, which raises `OSError: [Errno 22] Invalid argument` on Windows for negative values.

In my collection exactly 5 cards matched `queue IN (1,4) AND due < 0`; all had `odid != 0` and were in the same filtered deck. Emptying that filtered deck made the sync succeed immediately.

**Steps to reproduce (Windows)**

1. Build a filtered deck and answer a card in it with **Again** so it stays in intraday learning (`queue = 1`).
2. Call `getDecks` (or `cardsInfo`) with that card’s ID.
3. The call returns `[Errno 22] Invalid argument`.

**Workaround**

Empty the filtered deck, run the request, then rebuild the deck.

**Suggested fix**

Don’t treat `due` as a timestamp when `card.odid != 0` and `due < 0` (report it as a position instead), or guard `timestamp()` against negative / out-of-range values.

(I checked the latest commits on git.sr.ht/~foosoft/anki-connect up to 26.10.12.2 — the search-snapshot fix is there, but `state_record()` is unchanged, so this still seems to apply.)
