Skip to content

read_marker: Tolerate backfilled events in private read markers - #566

Open
ruka-hamanasu wants to merge 2 commits into
matrix-construct:devfrom
ruka-hamanasu:read-marker-backfilled
Open

read_marker: Tolerate backfilled events in private read markers#566
ruka-hamanasu wants to merge 2 commits into
matrix-construct:devfrom
ruka-hamanasu:read-marker-backfilled

Conversation

@ruka-hamanasu

Copy link
Copy Markdown

What does this PR do?

Posting m.read.private at a backfilled event failed the entire /read_markers request with M_INVALID_PARAM. In a room joined over federation where the latest message predates the join, every message a client can target is backfilled, so no read marker, public receipt, or notification reset could ever be posted there; the room stayed unread for such clients forever.

A backfilled position orders below every live event, so storing it can never advance the marker. Skip the write like a non-advancing receipt instead of erroring: the request succeeds, the accompanying public receipt and fully-read marker are still stored, and the notification-count reset on advance still runs.

The client/server spec says nothing about backfilled events, so the error appears to be from a desire to indicate to clients that they requested something Tuwunel couldn't entirely fulfill rather than indicating a request that was truly invalid from a protocol standpoint. In the case I tested, it was a request to set the read marker to the same event it was already on, so a no-op in terms of moving the read marker, but an important one because otherwise the client will never show the room as read. Worst case, it should be harmless to accept and skip, because it's not like clients do anything useful with the 400 error.

Fairly niche case, but also an extremely simple fix.

Checklist

  • Code is formatted with nightly cargo fmt and satisfies clippy and
    rustc lints; any allowed lint is justified by an obvious reason or a
    comment.
  • Complement compliance changes (new passes or new failures), if any,
    are noted in the description above.
  • [n/a] Config option changes were made in src/core/config/mod.rs doc
    comments and the regenerated tuwunel-example.toml is committed.
  • [n/a] User-facing changes are reflected in docs/.
  • I agree that my changes may be licensed under the Apache-2.0 licence
    and my conduct is in line with the Contributor's Covenant and
    Tuwunel's Code of Conduct.

Ruka Hamanasu added 2 commits August 28, 2026 19:05
Posting m.read.private at a backfilled event failed the entire
/read_markers request with M_INVALID_PARAM. In a room joined over
federation where the latest message predates the join, every message
a client can target is backfilled, so no read marker, public receipt,
or notification reset could ever be posted there; the room stayed
unread for such clients forever.

A backfilled position orders below every live event, so storing it
can never advance the marker. Skip the write like a non-advancing
receipt instead of erroring: the request succeeds, the accompanying
public receipt and fully-read marker are still stored, and the
notification-count reset on advance still runs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant