Repository navigation
fix(portal): asset pages and share links no longer answer 404 (#2205) - #2207
Merged
Merged
Conversation
Changes internal/ui/embed.go, adds internal/ui/routes_test.go and test/acceptance/issue_2205_test.go, and changes scripts/release-acceptance.sh; one bug and the gate that would have caught it: 1. #2205: since v1.147.0 every /portal/assets/{id} answered Go's plain 404. That covers a share link after its redirect for a signed-in reader, notification links, save_asset's portal_url and a reload of an open asset. The asset viewer route shares the prefix of Vite's build files, and the #2139 rule answered 404 for any path under assets/ the build does not have. A path there is now a build file only when it has an extension: every file Vite writes has one and an asset id never does. A missing .js or .css under /portal/assets/ still answers 404. 2. #2206: TestSPAHandler_EveryPortalRouteServesIndexHTML serves every page in the screenshot route manifest (ui/e2e/screenshots/route-*.ts, ids filled in) through the SPA handler and requires index.html; it fails when the manifest stops listing the asset viewer. TestBuildAssetsDir_MatchesViteConfig holds the Go prefix to Vite's build.assetsDir. make verify-release now runs make frontend-e2e-public-viewer against the stack its acceptance step uses, after building the portal the binary embeds (verify's embed-clean leaves it empty). That suite loads /portal/assets/{id} from the binary and failed on v1.147.0, but no target ran it. Also: docs/server/content-viewers.md, llms.txt, llms-full.txt and the Makefile help line say verify-release runs the live-stack suite. Closes #2205 Closes #2206
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2207 +/- ##
=======================================
Coverage 94.82% 94.82%
=======================================
Files 1361 1361
Lines 110409 110410 +1
=======================================
+ Hits 104696 104698 +2
+ Misses 5695 5694 -1
Partials 18 18 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
internal/ui/embed.go, addsinternal/ui/routes_test.goandtest/acceptance/issue_2205_test.go, and changesscripts/release-acceptance.sh. It fixes one bug and adds the gate that would have caught it.1. #2205:
/portal/assets/{id}answers 404 since v1.147.0Since v1.147.0 every request for
/portal/assets/{id}gets Go's plain-text404 page not foundinstead of the portal. That breaks:/portal/view/{token}) for a signed-in reader, which redirects there (pkg/portal/public.go:183)internal/platform/notifylayer/publish.go:138)portal_urlthatsave_assetand the trino, api and graphql exports returnNavigating inside the portal kept working because it never asks the server for the page.
Cause. #2146 (for #2139) made the SPA handler answer 404 for any path under
assets/that the build doesn't have. That way a page from another build can't getindex.htmlunder a stylesheet's or a chunk's URL. The portal is served under/portal/, so Vite's build files are at/portal/assets/*. The asset viewer route is/assets/:id, so it is under the same prefix, and every asset URL matched the rule.Fix. A path under
assets/counts as a build file only when it has an extension (isBuildFile). Every file Vite writes there has one. Asset ids are hex (pkg/toolkits/portal/toolkit.gogenerateID) and never do. A missing.jsor.cssunder/portal/assets/still answers 404, so the #2139 guarantee holds.2. #2206: the gate
Three suites could have caught this, and none did:
internal/uiunit tests asked only for/,/dashboardand build files.internal/ui.ui/e2e/public-viewer/parquet-viewer.spec.ts("renders a portal asset by range") loads/portal/assets/{id}from the Go binary and fails on v1.147.0. Onlymake frontend-e2e-public-viewerruns it, and neithermake verify,make verify-releasenor CI called that target.This PR adds:
TestSPAHandler_EveryPortalRouteServesIndexHTML. It reads every page in the screenshot route manifest (ui/e2e/screenshots/route-*.ts, concrete paths with ids filled in), sends each through the SPA handler and requiresindex.html. It fails when the manifest stops listing the asset viewer, so it can't silently stop covering this case. Restoring the v1.147.0 rule makes it fail, along withTestSPAHandler_AssetViewerRoute_ServesIndexHTML.TestBuildAssetsDir_MatchesViteConfig. It fails whenui/vite.config.tssets abuild.assetsDirthat differs from the Go constant.make verify-releaseruns the live-stack suite.scripts/release-acceptance.shrunsmake frontend-e2e-public-viewerafter the acceptance tests, against the same stack. When the script starts that stack itself, it first runsmake frontend-build, becauseverify'sembed-cleanleaves the embed directories empty and the binary would otherwise serve no portal.Acceptance
Run against the local dev stack (
make dev) built from this branch with the portal embedded. The transcript is inbuild/2205/acceptance.md.Wire forms:
save_assetwith its content as a string, its one form; the share create as one JSON object of strings; plain HTTP GETs of the share link with the dev API key as Bearer, and of the asset page with no credential.TestIssue2205_AShareLinkOpensTheAssetInThePortal: a signed-in GET of/portal/view/{token}answers 302 to/portal/assets/{id}?share={token}, and that page answers 200text/htmlwith the portal'sindex.html.TestIssue2205_AnAssetsPortalURLOpensThePortal: the path ofsave_asset'sportal_urland/portal/assets/{id}/provenanceeach answer the portal'sindex.html.make acceptance ISSUE=2139against the same stack: both criteria pass. A missing build file still answers 404, and a present one is served as itself.make frontend-e2e-public-vieweragainst the same stack: 27 passed.Verification
make verifypassed (log inbuild/2205/verify.txt).make preverify-fast, the patch-scopedmake lint,make semgrep-diffand shellcheck on the script are clean.Readers of this state
No JSON field and no route changed.
index.htmlis now served for paths under/portal/assets/that have no extension, which is what v1.146.2 and earlier served there.Closes #2205
Closes #2206