Uh oh!
There was an error while loading. Please reload this page.
[codex] Structure preview asset URL failures - #3399
Conversation
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Approved This PR refactors error handling for browser preview asset URLs, converting to Schema-based error classes with structured context fields while ensuring sensitive data isn't leaked. The changes are limited to error infrastructure with comprehensive test coverage. You can customize Macroscope's approvability policy. Learn more. |
6989347 to
199dc14CompareDismissing prior approval to re-evaluate 199dc14
199dc14 to
c048ffeCompareDismissing prior approval to re-evaluate c048ffe
e27816d to
118514fComparec048ffe to
215b085Compare118514f to
c3688f1Compare215b085 to
8751fdbComparec3688f1 to
ca92705Compare8751fdb to
087f4d1Compareca92705 to
f689d14Compare087f4d1 to
8c4c9b9Comparef689d14 to
5a8a7d1Compare8c4c9b9 to
e2f90b8Compare5a8a7d1 to
7367e8aComparee2f90b8 to
0de1a6fCompare7367e8a to
01b1b93Compare8184293 to
6604762CompareDismissing prior approval to re-evaluate 6604762
6604762 to
83d49a1Compare01b1b93 to
9214cdfCompare83d49a1 to
5dc67afCompare9214cdf to
23b0b8eCompare5dc67af to
b6ec6cfCompare23b0b8e to
f3b05eaCompareb6ec6cf to
9952de4Comparef3b05ea to
1a24dccCompare6c4608c to
f1b1d68Comparee6a4567 to
7ef6bc2Comparef1b1d68 to
6e21cc7Compare7ef6bc2 to
b74fe0bCompare6e21cc7 to
2d0461bCompareCo-authored-by: codex <codex@users.noreply.github.com>
b74fe0b to
1824661Compare2d0461b to
56e0750CompareUh oh!
There was an error while loading. Please reload this page.
Summary
BrowserPreviewAssetUrlInvalidErrorScope
apps/web/src/browser/openFileInPreview.tsand its focused testChatMarkdownreporting are intentionally deferred until feat(web): preview workspace images from chat and diffs #3259 and [codex] Report markdown interaction failures #3355 are integratedStack dependency
codex/stack-pr-3259mirrors the exact fork head of draft feat(web): preview workspace images from chat and diffs #3259 because GitHub cannot directly target a fork branch as this PR basemainand retarget the PR tomainValidation
pnpm vp test apps/web/src/browser/openFileInPreview.test.tspnpm vp checkpnpm vp run typecheckNote
Medium Risk
Changes integrated-browser open paths and error typing in chat markdown; invalid asset URLs now fail recoverably instead of dying, with safer diagnostics around signed URLs.
Overview
Preview asset URL construction in
openFileInPreviewno longer usesresolveAssetUrlorCause.diewhen the base/relative URL pair is invalid. It builds the URL withnew URL(relative, base)and returnsBrowserPreviewAssetUrlInvalidErrorviaCause.fail, carrying environment/thread/file context, URL lengths and expiry, and the original parser cause—without storing raw base or signed relative URLs.Browser preview errors are refactored to Effect
Schema.TaggedErrorClasstypes with fixed user-facing messages:BrowserPreviewUnavailableError(runtime unsupported), plus newBrowserPreviewThreadContextUnavailableErrorandBrowserPreviewEnvironmentDisconnectedError.ChatMarkdownreturns these specific failures when opening links or workspace files in the integrated browser instead of overloadingBrowserPreviewUnavailableErrorwith ad hoc messages.Tests in
openFileInPreview.test.tscover the fixed unavailable message, invalid-asset-URL diagnostics, cause identity, and that serialized errors do not leak signed tokens.Reviewed by Cursor Bugbot for commit 56e0750. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Structure browser preview asset URL failures as typed errors in
openFileInPreviewSchema.TaggedErrorClasserrors for three new failure cases: missing thread context (BrowserPreviewThreadContextUnavailableError), disconnected environment (BrowserPreviewEnvironmentDisconnectedError), and invalid asset URL (BrowserPreviewAssetUrlInvalidError).BrowserPreviewAssetUrlInvalidErrorcaptures safe diagnostic fields (environmentId,threadId,filePath,httpBaseUrlLength,relativeUrlLength,expiresAt) and preserves the original cause, avoiding exposure of sensitive URL contents.resolveAssetUrlwith anew URL(relativeUrl, httpBaseUrl)call wrapped in try/catch; failures are surfaced asBrowserPreviewAssetUrlInvalidErrorinstead of a defect die.isBrowserPreviewAssetUrlInvalidErroras a type guard viaSchema.is.openFileInPreviewnow receive typed failures for URL construction errors instead of unhandled defects.Macroscope summarized 56e0750.