fix: skip raw on open, validate folders, decode cached subjects, map move conflicts - #55
Merged
TheGreatAxios merged 1 commit intoSep 27, 2026
Conversation
TheGreatAxios
added this pull request to stack #50
September 27, 2026 00:56
TheGreatAxios
force-pushed
the
cl-9437-mailbox-stop-loading-raw-bytes-on-open-validate-folders
branch
from
September 27, 2026 01:23
e9377ab to
b1a1a03
Compare
…move conflicts openNativeMailboxStore no longer selects raw, since readRaw fetches it on demand, so a list or mark-read does not load every frame in the folder. POST /me/inbox/:uid/read and /unread 400 on a ?folder= outside INBOX, Sent, Archive and Trash instead of creating a mailbox_state row for it, and restore 400s on any source but Archive or Trash. persist caches the Subject with its RFC 2047 encoded-words decoded (@intx/mime has no decoder). A word that does not decode (bad base64, bytes invalid in its charset, an unknown charset) stays as written, and whitespace is dropped only between two encoded-words. moveNativeMailboxMessage runs in one transaction, so a failed move burns no uid. The move routes answer 404 only when the uid is missing, 409 when the destination already holds the Message-ID from the same sender, and 500 on anything else, such as a database outage.
TheGreatAxios
force-pushed
the
cl-9437-mailbox-stop-loading-raw-bytes-on-open-validate-folders
branch
from
September 27, 2026 01:39
b1a1a03 to
0bb3dbe
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
openNativeMailboxStoreno longer selectsraw.readRawfetches it when needed, so a list or mark-read no longer loads every frame in the folder.POST /me/inbox/:uid/readand/unreadreturn 400 for a?folder=outside INBOX, Sent, Archive and Trash, so an unknown folder never creates amailbox_staterow.restorereturns 400 for any source except Archive or Trash (the README says so).@intx/mimehas no decoder, sodecodeEncodedWordslives inframe.ts. A word that does not decode (invalid base64, bytes invalid in its charset, an unknown charset) is left as written, and whitespace is dropped only between two encoded-words that both decode, never after a literal?=or before an undecodable word.moveNativeMailboxMessageruns in one transaction, so a failed move burns no uid. It locks both folders'mailbox_staterows up front in folder order, so opposite-direction moves queue instead of deadlocking. The archive/trash/restore routes return 404 only when the uid is missing, 409 when the destination already holds the Message-ID from the same sender (Postgres 23505), and 500 for anything else, such as a database outage.Verification
e2e/mount-native.test.ts:restore?folder=INBOX|Sent|junkis 400;read/unread?folder=junkis 400 with nomailbox_staterow; archiving onto a Message-ID Archive already holds is 409 with both folders'uid_nextunchanged; a move against a closed connection is 500. 8 archive and 8 restore moves run interleaved return only 200/404/409 and leave 16 distinct rows with distinct (folder, uid); on fix(routes): harden POST /me/inbox/send #54 it gets deadlock 500s.e2e/persist.test.ts:=?UTF-8?B?w6nDqcOp?=is cached asééé.src/frame.test.tsunit-testsdecodeEncodedWords, including=?UTF-8?B?!!!!?=and a truncated UTF-8 sequence staying as written, andplain?= =?UTF-8?Q?b?=keeping its space, and=?UTF-8?Q?a?= =?UTF-8?B?!!!!?=keeping the space before the undecodable word.rawcolumn directly; thereadRawtests cover it.bun run check, build,test:e2eand the pack smoke pass locally.Closes CL-9437