Write HTML. Render video. Built for agents.
JavaScript aiai-agentsanimationclaude-codeffmpegframeworkgsaphtmlhtml-to-videomcpmotion-graphicspuppeteerrenderingtypescriptvideo-editor
fix(studio-server): make sub-composition ETags ByteString-safe (#3982)
heygengenesis[bot]edb6e87ba7fa
diff --git a/packages/studio-server/src/routes/preview.test.ts b/packages/studio-server/src/routes/preview.test.tsindex 4d7fc378c6..6420b38bdd 100644--- a/packages/studio-server/src/routes/preview.test.ts+++ b/packages/studio-server/src/routes/preview.test.ts@@ -464,6 +464,35 @@ describe("hf-id surfacing in preview route", () => {expect(readFileSync(compPath, "utf-8")).toContain('data-hf-id="hf-');});+ it("returns ByteString-safe stable and distinct ETags for percent-encoded CJK sub-comp paths", async () => {+ const projectDir = createProjectDir();+ mkdirSync(join(projectDir, "compositions"));+ writeFileSync(join(projectDir, "compositions/測試.html"), "<div>First</div>");+ writeFileSync(join(projectDir, "compositions/別頁.html"), "<div>Second</div>");+ const app = new Hono();+ registerPreviewRoutes(+ app,+ createAdapter(projectDir, { getProjectSignature: () => "stable-signature" }),+ );++ const first = await app.request(+ "http://localhost/projects/demo/preview/comp/compositions/%E6%B8%AC%E8%A9%A6.html",+ );+ const repeat = await app.request(+ "http://localhost/projects/demo/preview/comp/compositions/%E6%B8%AC%E8%A9%A6.html",+ );+ const other = await app.request(+ "http://localhost/projects/demo/preview/comp/compositions/%E5%88%A5%E9%A0%81.html",+ );++ expect([first.status, repeat.status, other.status]).toEqual([200, 200, 200]);+ const firstEtag = first.headers.get("ETag");+ expect(firstEtag).toBeTruthy();+ expect(firstEtag).toMatch(/^[\x20-\x7e]+$/);+ expect(repeat.headers.get("ETag")).toBe(firstEtag);+ expect(other.headers.get("ETag")).not.toBe(firstEtag);+ });+it("sub-comp served ids equal disk ids even when relative asset paths are rewritten", async () => {// Regression guard for the setTiming element_not_found divergence class:// the sub-comp route rewrites relative src/href BEFORE minting, so andiff --git a/packages/studio-server/src/routes/preview.ts b/packages/studio-server/src/routes/preview.tsindex 753909522b..4ed13a4f59 100644--- a/packages/studio-server/src/routes/preview.ts+++ b/packages/studio-server/src/routes/preview.ts@@ -470,7 +470,8 @@ export function registerPreviewRoutes(api: Hono, adapter: PreviewApiAdapter): vo// "v2" salts the etag for the hf-id-pinning change below: a client holding// a pre-pin cached response (preview-only ids, unstamped disk file) must// not revalidate to a 304 that skips the pin.- const etag = `"comp:v2:${compPath}:${signature}${variablesEtagSalt(vars.raw)}"`;+ const compPathHash = createHash("sha1").update(compPath).digest("hex");+ const etag = `"comp:v2:${compPathHash}:${signature}${variablesEtagSalt(vars.raw)}"`;const ifNoneMatch = c.req.header("If-None-Match");if (ifNoneMatch === etag) {return new Response(null, {