Skip to content

bug(imap): APPEND response hardcodes UIDVALIDITY=1 in APPENDUID code #83

@ssilvius

Description

@ssilvius

Problem

`handleAppend` in `packages/imap/src/commands/extensions.ts` hardcodes `1` as the UIDVALIDITY value in the `APPENDUID` response code:

```typescript
// RFC 4315: APPENDUID response code
return [formatTagged(tag, "OK", `[APPENDUID 1 ${result.uid}] APPEND completed`)];
```

Per RFC 4315 Section 3, the `APPENDUID` response code is `APPENDUID `. The uidValidity must be the current mailbox UIDVALIDITY, not a constant. Clients correlate their local UID cache against the (uidValidity, uid) tuple -- if uidValidity changes and the client sees a stale `1`, it may believe its cache is still valid when it is not, or it may invalidate incorrectly when an unrelated mailbox swaps in.

Fix scope

  1. `handleAppend` needs access to the target mailbox's `uidValidity`. The mailbox adapter already returns `uidValidity` from `getFolderStats`; the APPEND handler should fetch it (or receive it as a parameter) before emitting the response.
  2. Update the response line to use the real uidValidity
  3. Add a test referencing RFC 4315 Section 3 that asserts APPENDUID uses the actual mailbox uidValidity across mailboxes with different UIDVALIDITY values.

Related

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