Send a filter the server can read #72

Closed
opened 2026-08-26 21:01:46 +00:00 by jcoffey-dev · 0 comments
Owner

Enabling "Notify me even when ihasmail is closed" failed with Invalid filter. My bug, found in the live test that was the only way to find it.

-filter: { inMailbox: null, notKeyword: "$seen" }
+filter: { ...(inboxId ? { inMailbox: inboxId } : {}), notKeyword: "$seen" }

inMailbox: null meant "the inbox" in my head and nothing at all to Stalwart, which needs a mailbox id there. It refused the whole subscription — so the feature didn't work for anyone who tried it, not just in some edge case.

The Inbox id now comes from useMail.roleId("inbox") and is passed in. Where it isn't known the condition is left out rather than sent empty: notifying more widely is a worse default than filtering to the Inbox, but it's a working one, and a malformed filter isn't a fallback.

Why it got out

Two failures, both fixed rather than just the symptom.

The tests never looked at the filter. They checked that properties contained from and subject and that ordering put from before preview — thorough about the part I was thinking about, silent on the part I got wrong. There's now a test walking every filter condition and failing on a null or undefined value, covering both the known-inbox and unknown-inbox paths.

The mock accepted it. Nothing local disagreed with the code, so the whole thing looked verified. It now refuses a filter condition with a null value and answers Invalid filter. — the live server's own wording. Demonstrated both ways:

old payload → notCreated: { type: "invalidArguments",
                            properties: ["emailPush"],
                            description: "Invalid filter." }
new payload → created: { id: "ps813603" }

That second fix matters more than the first. This mock has been taught to reproduce every bug that reached a real server — the capability placement, the calendar vocabulary, padded push keys — and this is one more.

265 web + 75 server tests, typecheck and build clean.

Still unverified: an actual notification arriving. That needs another live test after this deploys.

Merged 2026-08-26 as coffey-labs/ihasmail@99e98f82f3

Rebuilt from: git history, session transcript.

Enabling **"Notify me even when ihasmail is closed"** failed with `Invalid filter`. My bug, found in the live test that was the only way to find it. ```diff -filter: { inMailbox: null, notKeyword: "$seen" } +filter: { ...(inboxId ? { inMailbox: inboxId } : {}), notKeyword: "$seen" } ``` `inMailbox: null` meant "the inbox" in my head and nothing at all to Stalwart, which needs a mailbox id there. It refused the whole subscription — so the feature didn't work for anyone who tried it, not just in some edge case. The Inbox id now comes from `useMail.roleId("inbox")` and is passed in. Where it isn't known the condition is **left out** rather than sent empty: notifying more widely is a worse default than filtering to the Inbox, but it's a working one, and a malformed filter isn't a fallback. ## Why it got out Two failures, both fixed rather than just the symptom. **The tests never looked at the filter.** They checked that `properties` contained `from` and `subject` and that ordering put `from` before `preview` — thorough about the part I was thinking about, silent on the part I got wrong. There's now a test walking every filter condition and failing on a null or undefined value, covering both the known-inbox and unknown-inbox paths. **The mock accepted it.** Nothing local disagreed with the code, so the whole thing looked verified. It now refuses a filter condition with a null value and answers `Invalid filter.` — the live server's own wording. Demonstrated both ways: ``` old payload → notCreated: { type: "invalidArguments", properties: ["emailPush"], description: "Invalid filter." } new payload → created: { id: "ps813603" } ``` That second fix matters more than the first. This mock has been taught to reproduce every bug that reached a real server — the capability placement, the calendar vocabulary, padded push keys — and this is one more. 265 web + 75 server tests, typecheck and build clean. Still unverified: an actual notification arriving. That needs another live test after this deploys. **Merged** 2026-08-26 as coffey-labs/ihasmail@99e98f82f37a <sub>Rebuilt from: git history, session transcript.</sub>
This repo is archived. You cannot comment on issues.