Skip to content

feat(media): add validated upload adapter - #111

Open
xyh202131 wants to merge 2 commits into
1024XEngineer:mainfrom
xyh202131:feat/media-upload
Open

feat(media): add validated upload adapter#111
xyh202131 wants to merge 2 commits into
1024XEngineer:mainfrom
xyh202131:feat/media-upload

Conversation

@xyh202131

Copy link
Copy Markdown

Summary

  • add a real multipart media upload adapter for POST /media/upload
  • validate the response envelope and media DTO before returning MediaReference
  • expose the adapter through the Entity public entrypoint
  • propagate HTTP, business, contract and abort errors without mock success
  • fail explicitly when VITE_API_BASE_URL is missing instead of posting to the visitor's localhost

Scope

Frontend only. No page, WorkflowRun, Controller, backend, object-storage configuration, database, log or build artifact is included.

Verification

  • changed-file format check: passed
  • lint: passed
  • typecheck: passed
  • tests: 3 files, 14 tests passed
  • production build: passed
  • repository-wide format:check remains blocked by 41 pre-existing files on main; this PR does not mix those unrelated rewrites into the upload feature

Closes #109

@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
windup Ready Ready Preview Aug 6, 2026 12:44pm

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One issue found: the upload helper currently turns aborts that happen while reading the response body into UploadRequestError, so cancellation is no longer distinguishable from a real failure after fetch has resolved.

Comment thread frontend/src/shared/api/upload.ts Outdated
async function readResponseBody(response: Response): Promise<unknown> {
try {
return await response.json()
} catch {

@fennoai fennoai Bot Aug 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Result

Implemented the requested fix locally, but could not push it to xyh202131:feat/media-upload from this runner.

Changed:

  • Re-threw AbortError from response.json() so late upload cancellations stay distinguishable from upload failures.
  • Added a regression test for aborts thrown while reading the response body.

Verified:

  • npm test -- --run src/entities/media/api.test.ts passed: 1 file, 13 tests.
  • npm run lint passed.
  • npm run typecheck passed.

Not completed:

  • Push failed for https://github.com/xyh202131/Windup.git with GitHub authentication rejection, so local commit d16a6fd is not on the PR branch.
  • The pre-created FennoAI reply comment 3728817988 became inaccessible via the GitHub API after the initial progress update, so this visible parent thread was updated instead.

View job run

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fennoai 帮我改一下你说的问题

@fennoai fennoai Bot Aug 6, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Result

现在看 PR 分支已经包含修复提交了:633d96f (fix(media): preserve late upload cancellation)。

它修的是我前面指出的问题:response.json() 在读取响应体阶段如果抛出 AbortError,现在会原样重新抛出,不再被包装成 UploadRequestError。同时补了对应的回归测试。

验证通过:

  • npm test -- --run src/entities/media/api.test.ts:1 个文件、13 个测试通过
  • npm run lint:通过
  • npm run typecheck:通过

View job run

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.

feat: 实现前端媒体上传适配与错误边界(Refs #70)

2 participants