Skip to content

fix(workspaces): surface real reason when file upload fails#604

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/surface-office-upload-conversion-error
Draft

fix(workspaces): surface real reason when file upload fails#604
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/surface-office-upload-conversion-error

Conversation

@posthog

@posthog posthog Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

What

When a workspace file upload fails, the client now surfaces the real server reason instead of a context-free message.

The upload queue (AsyncQueuer in workspace-file-upload.ts) runs with throwOnError: false, so each per-job failure was swallowed. When every job failed, onSettled threw a generic Failed to upload <name>. — and that empty message is what landed in error tracking, discarding the actual cause (for Office files, a 422 CONVERSION_FAILED from the LibreOffice/Gotenberg office_to_pdf path).

The fix captures per-job errors via the queuer's onError callback and folds the deduped reason(s) into the thrown error, attaching the underlying failure as error.cause so error tracking keeps the server context.

Why

An Office (.pptx) upload was failing repeatedly, but error tracking only ever saw Failed to upload <name>. with no reason — so we couldn't tell whether the conversion container timed out, LibreOffice choked on the deck, or the PDF came back empty. This restores that visibility.

Note: this addresses the reported symptom (the client throwing away the real reason). The specific root cause of that one .pptx conversion can't be determined retroactively — the reason was discarded before this fix — but future occurrences will now carry the real message (LibreOffice error / empty-PDF / 60s port-ready timeout) through to error tracking.

Test plan

  • Added workspace-file-upload.test.ts covering a single Office conversion failure: asserts the thrown error includes the server reason and carries the underlying failure as error.cause.
  • pnpm check (format + lint + types) and pnpm test pass.

Created with PostHog Code from an inbox report.


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

Review in cubic

The AsyncQueuer that drives workspace file uploads runs with
throwOnError: false, so per-job failures were swallowed and onSettled
threw a context-free "Failed to upload <name>." That generic message is
what reached error tracking, discarding the real server reason (e.g. a
422 CONVERSION_FAILED from the office->PDF path).

Capture per-job errors via the queuer's onError callback and fold the
real reason(s) into the thrown error, attaching the underlying failure
as `error.cause` so error tracking keeps the server context.

Generated-By: PostHog Code
Task-Id: 1efb7646-83c0-4822-9cee-64d6bcbb4d16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

0 participants