Repository navigation
refactor(media): reuse guarded remote media downloads - #117771
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed August 1, 2026, 11:30 PM ET / August 2, 2026, 03:30 UTC. ClawSweeper reviewWhat this changesThe branch routes remote URL inputs to the media store through the canonical SSRF-guarded remote-media saver, removes the older handwritten downloader, and updates focused delegation and boundary tests. Merge readinessThe PR appears to be the right owner-boundary refactor: current Priority: P2 Review scores
Verification
How this fits togetherThe media store accepts local paths and remote URLs and persists validated private media for plugin and runtime consumers. Remote URLs pass through network protections before the resulting file is atomically saved and exposed through the store result contract. flowchart LR
A[Remote media URL] --> B[Media store]
B --> C[Lazy remote-media adapter]
C --> D[Guarded fetch and redirect policy]
D --> E[Validated private media file]
E --> F[Plugin and runtime consumers]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -204, Tests -388. Total -592 across 6 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep one canonical guarded remote-media ingestion flow, retain the small lazy boundary that prevents the store/fetch cycle, and land only after the exact head’s remaining checks and security-path review confirm no dispatcher or upgrade regression. Do we have a high-confidence way to reproduce the issue? Not applicable as a defect reproduction: this PR refactors an existing remote-media path. The branch supplies focused source-level boundary coverage for the changed behavior, but this review did not execute the untrusted PR branch. Is this the best way to solve the issue? Yes. Current main has two owners for the same guarded remote-download responsibility; routing the store through AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 14322647cd6c. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
What Problem This Solves
Remote media saved through the media store used a second handwritten HTTP downloader instead of the canonical guarded media-fetch owner. This duplicated redirect, DNS, timeout, size-limit, streaming, and temporary-file policy and made those safety rules easier to drift.
Why This Change Was Made
Route
saveMediaSourceURL inputs through the existing SSRF-guardedsaveRemoteMediaowner, retain a narrow lazy module boundary to avoid the store/fetch import cycle, and delete the obsolete downloader. A small fetch adapter immediately cancels ignored error bodies, preserving the existing prompt rejection even when response-body cancellation itself never resolves.User Impact
Remote media downloads retain strict DNS and redirect protection, cross-origin credential stripping, configured size and timeout limits, atomic private-file publication, MIME/extension behavior, and immediate rejection of hostile HTTP error responses. This removes 201 handwritten production lines and 592 lines overall without changing the shipped media-store result contract.
Evidence
ReadableStream.cancel()still rejects immediately.pnpm check:changed: passed (17m31s).pnpm build: passed (2m52s), including plugin assets, runtime postbuild, plugin SDK exports, and the UI build.src/media/fetch.tsandsrc/media/fetch.test.tsremain untouched, avoiding unrelated active PR ownership.