Skip to content

web: report an incomplete export transfer separately from unreachable - #236

Merged
TusanHomichi merged 1 commit into
mainfrom
issue-129-export-incomplete-message
Nov 20, 2026
Merged

TusanHomichi merged 1 commit into
mainfrom
issue-129-export-incomplete-message

Conversation

@TusanHomichi

Copy link
Copy Markdown
Member

Primary Issue

Closes #129

Problem And Outcome

downloadExport reads the streamed export response into a Blob before saving it so a truncated transfer can never save a partial file. Previously, when a transfer started (200 OK) and then cut off mid-body, response.blob() threw a non-ApiError and every caller fell back to "the server could not be reached", telling the operator the wrong cause and wrong next step.

downloadExport now distinguishes all three outcomes through a single error boundary:

  1. Typed server refusal (ApiError) → the server's own message.
  2. Transfer started (2xx) and cut off while reading the body (IncompleteExportError) → "the export did not finish; download it again", with no download saved.
  3. Connection failure before headers arrive → "the server could not be reached".

Changes

  • web/src/lib/api/exports.ts
    • Added IncompleteExportError and wrapped await response.blob() so mid-transfer read failures throw IncompleteExportError before URL.createObjectURL or <a download> runs.
    • Added describeExportError(err) as the single owning formatter for downloadExport errors.
  • web/src/lib/exports/ExportsCard.svelte, web/src/routes/drafts/[id]/+page.svelte, web/src/routes/records/+page.svelte, web/src/routes/enrollments/[id]/+page.svelte
    • Routed every export download catch block through describeExportError(err).
  • web/e2e/installation-export.spec.ts
    • Added a browser test using a transparent loopback HTTP proxy in front of the real compiled consolebook-server covering: (1) a 200 OK chunked transfer cut off mid-body with no terminal chunk ("the export did not finish; download it again", 0 downloads), (2) a typed 503 export_busy refusal (server message, 0 downloads), (3) a pre-header connection abort ("the server could not be reached", 0 downloads), and (4) an unobstructed retry that downloads and passes consolebook-server export verify.

Why not split: drafts/[id]/+page.svelte and enrollments/[id]/+page.svelte already exceed 1,000 lines and this change only replaces their 1-line catch formatter with the shared describeExportError helper without adding new page behavior.

Verification

Red-first check (before the fix)

Running npx playwright test e2e/installation-export.spec.ts -g "cut off mid-transfer" against unfixed code failed on step 1 as expected:

  • Expected: "the export did not finish; download it again"
  • Received: "the server could not be reached"

Local proof receipt — passed

  • Candidate: caa6f41dd44aabad4ff705cd912360d53b218b4e tree b763a60dcbe5cb2cdda7d2f6eae663d12fcfc9a4; unchanged during run: true
  • Scope: local (local run; hosted pr-gate results are separate evidence, linked not copied)
  • Command: cargo xtask proof in /data/dev/src/consolebook
  • Started 2026-11-20T15:42:28Z, finished 2026-11-20T15:56:43Z, 854.8s
  • Sequence source: CONTRIBUTING.md sha256 87f297e8dad4868f1364b29eb9a45b372ca3dc34e8e205c3505d15883036daa5
  • Browser: playwright-managed /home/dev/.cache/ms-playwright/chromium-1254/chrome-linux64/chrome (Google Chrome for Testing 158.0.8127.18)
  • Host: Linux-6.18.64-x86_64; euid 1001; can bypass file permissions: false (from CapEff)
  • Toolchain: rustc 1.99.1 (58cf8f9c3 2026-10-13); node v22.23.5; npm 10.9.9
  • Binary: target/debug/consolebook-server sha256 c54ae11fa28928868b8dbe95fb68efac379b4cfed55dd58a3a0ebb6588b90487
  • Web build manifest: 54 files, sha256 8f2232a5faec705e7a046e9e44799d9598806fd4a2434ff424dfe22066c38196
  • Browser suite: 71 expected, 0 unexpected, 0 flaky, 0 skipped; report sha256 f1526d89edc5f2edd98b101ceefa6461d5b0cb8ad39d5f6474e1f8efa3bd20f7
# Command Status Exit Seconds Log sha256 (prefix)
1 scripts/check-guidance-names.sh passed 0 0.081 01.log 2b172a8e66c87574
2 (cd web && npm ci && npm run check && npm run build) passed 0 28.668 02.log 3c26a20ee8e3046b
3 cargo fmt --check passed 0 1.6 03.log e3b0c44298fc1c14
4 cargo clippy --workspace --all-targets -- -D warnings passed 0 17.634 04.log a521a97fabed0c28
5 cargo test --workspace passed 0 314.304 05.log 5ce0737a18d0f116
6 cargo build -p consolebook-server passed 0 0.472 06.log dd621e9ff7c9eac1
7 (cd web && npx playwright install chromium && npm run e2e) passed 0 492.066 07.log 8aaa68537bef2942

Review And Merge Notes

  • Correction ladder rung: Rung 1 (Codebase) + Rung 2 (Mechanical enforcement) — introduced typed IncompleteExportError and single describeExportError formatter across all export callers, with an end-to-end truncated-chunked-stream browser test.
  • All fixtures are invented; no Rust or schema changes.

Wrap mid-body response.blob() failures in IncompleteExportError so an export cut off after 2xx headers tells the operator 'the export did not finish; download it again' without saving a partial file, while preserving typed ApiError refusals and pre-header connection errors across every export caller.

Closes #129
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T15:58:55.767797Z caa6f41 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@fieldmouseworks-steward fieldmouseworks-steward Bot added the waiting: review Its reviewers, or a Claude job judging it, are looking at this head label Nov 20, 2026
@TusanHomichi
TusanHomichi merged commit 0257fdc into main Nov 20, 2026
23 of 24 checks passed
@TusanHomichi
TusanHomichi deleted the issue-129-export-incomplete-message branch November 20, 2026 16:26
@fieldmouseworks-steward fieldmouseworks-steward Bot removed the waiting: review Its reviewers, or a Claude job judging it, are looking at this head label Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

web: an export cut off mid-transfer says the server could not be reached

1 participant