Misleading error message and architectural limitations in JMAP FileNode/copy (same-account & recursive directory copy)

Issue Description

When invoking FileNode/copy, if account_id equals from_account_id, the server rejects the request with the error detail:
“From accountId is equal to fromAccountId”.

Expected Behavior

A clearer error message

Stalwart Version

v1.x

Installation Method

Binary (Linux)

Database Backend

RocksDB

Blob Storage

S3-compatible

Search Engine

Internal

Directory Backend

Internal

Additional Context

Can FileNode/copy be extended to support intra-account copies, or is this restricted by design? FileNode/set is not good for copying folders (with recursive tree)

I have reviewed the documentation and FAQ and confirm that my issue is NOT addressed there.

on

I have searched this support forum (open and closed topics) and confirm this is not a duplicate.

on

I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.

on

Your reading of the code is right. FileNode/copy rejects a request when accountId equals fromAccountId, and this is deliberate.

I found the check in crates/jmap/src/file/copy.rs. It returns an invalidArguments error with the detail “From accountId is equal to fromAccountId”. The Email/copy, ContactCard/copy and CalendarEvent/copy handlers have the same check and the same message. This matches the JMAP core /copy definition, which is meant for copying between different accounts. A same-account copy isn’t supported through this method.

The message itself is worded badly, since it names the same field twice. Something like “accountId must differ from fromAccountId” would be clearer. I can’t promise a change to either the message or the behaviour. I also found nothing in the docs or source about recursive same-account folder copy. Whether FileNode/copy will be extended to cover it is for a maintainer to answer.

A client can copy a folder inside one account by calling FileNode/set to create the new folder node. It then has to walk the source tree and create each child with parentId pointing at the new parent. It can reuse the existing blobId for each file, so the file content isn’t re-uploaded. This is done client-side, and the server doesn’t do it for you.

This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong.

Hi Chris,

Rejecting same-account copies is intentional. In JMAP, Foo/copy exists to move records between two different accounts (RFC 8620, section 5.4), and FileNode/copy follows that.

To copy inside one account, use FileNode/set with create and reuse the existing blobId of each file, so nothing is uploaded or stored twice. A whole folder tree fits in one FileNode/set call: create the directories first and point the children at them with creation id references in parentId:

["FileNode/set", {
  "accountId": "A1",
  "create": {
    "d1": { "name": "Reports copy", "parentId": "<target dir id>" },
    "d2": { "name": "2026", "parentId": "#d1" },
    "f1": { "name": "q1.pdf", "parentId": "#d2", "blobId": "<existing blobId>" }
  }
}, "0"]

The client still has to walk the source tree (one FileNode/query or FileNode/get gives you the nodes and their blobIds), but it’s a single write. A server-side recursive copy would be a new method beyond the spec; if you’d like to see one, please post it in Feature Ideas.

The error text is now “accountId must differ from fromAccountId”, and the same wording is used for Email/copy, ContactCard/copy and CalendarEvent/copy. That change ships in next week’s Stalwart release.