different-ai/openwork · error

Failed to copy attachment "${metadata.filename}" into this w

Error message

Failed to copy attachment "${metadata.filename}" into this worker workspace: upload was rejected

What it means

After uploadInbox returns, the code checks result.ok. A false value means the server accepted the request but rejected the upload (e.g. quota, invalid path, storage failure), so it throws this per-file rejection message. Unlike the wrapped-throw case, the upload call itself did not throw.

Source

Thrown at apps/app/src/react-app/domains/session/sync/attachment-file-part.ts:381

      ? attachment.file
      : await compressImageFile(attachment.file);
    const metadata = resolveAttachmentFileMetadata(file);
    const id = input.createId ? input.createId() : randomAttachmentId();
    const inboxPath = buildChatAttachmentInboxPath({
      sessionId: input.sessionId,
      filename: metadata.filename,
      id,
    });

    let result: InboxUploadResult;
    try {
      result = await input.endpoint.client.uploadInbox(workspaceId, file, { path: inboxPath });
    } catch (error) {
      throw new Error(uploadErrorMessage(metadata.filename, error));
    }

    if (result.ok === false) {
      throw new Error(`Failed to copy attachment "${metadata.filename}" into this worker workspace: upload was rejected`);
    }
    if (!result.path.trim()) {
      throw new Error(`Failed to copy attachment "${metadata.filename}" into this worker workspace: upload did not return a path`);
    }
    if (result.bytes !== file.size) {
      throw new Error(`Failed to copy attachment "${metadata.filename}" into this worker workspace: expected ${file.size} bytes, wrote ${result.bytes}`);
    }

    const workspacePath = workspaceInboxPath(result.path);
    const absolutePath = joinWorkspaceRelativePath(workspaceRoot, workspacePath);
    uploaded.push({
      filename: metadata.filename,
      mime: metadata.mime,
      bytes: result.bytes,
      workspacePath,
      url: toFileUrl(absolutePath),
      file,
    });

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Check the server response/logs for the rejection reason and fix server-side constraints (quota, path policy).
  2. Retry the upload after freeing inbox space or correcting the path.
  3. Update client and server so both agree on the uploadInbox result contract.

Example fix

// after uploadInbox resolves: if (result.ok === false) { notify(`Upload rejected for ${file.name}: check server inbox policy/quota`) }
Defensive patterns

Strategy: try-catch

Validate before calling

const inboxStatus = await client.inboxStatus?.(workspaceId); if (inboxStatus && !inboxStatus.writable) { showToast('Workspace inbox is not writable; free space or fix policy'); return; }

Try / catch

try { await composerAttachmentsToWorkspaceFileParts({ attachments, endpoint, sessionId, workspaceRoot }); } catch (e) { if (String(e.message).includes('upload was rejected')) { showToast('Server rejected the upload — check inbox quota/policy'); } else { throw e; } }

Prevention

When it happens

Trigger: uploadInbox resolves with { ok: false } — server-side validation rejected the file, inbox storage refused the write, or the endpoint returned a structured failure for that path.

Common situations: Server inbox full or read-only; upload path violates server-side policy (reserved names/paths); version mismatch where client/server disagree on the upload contract.

Related errors


AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01). Data as JSON: /api/errors/7976502b0d34e883. Report an issue: GitHub.