Skip to content

Commit a59a55d

Browse files
DeRaowlclaude
andcommitted
fix(percy): force app-type project for screenshot clone
Web projects require DOM resources for snapshots — tile API is rejected with "param is missing: relationships". Always request app-type token for screenshot clone path. If target exists as web-type, creates companion "{name}-screenshots" project as app-type. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a001f0b commit a59a55d

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

src/tools/percy-mcp/v2/clone-build.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -319,32 +319,35 @@ export async function percyCloneBuildV2(
319319

320320
// ── Screenshot Clone via tile API ─────────────────────────────────────
321321
// Tile-based API preserves: exact snapshot names, all widths, all browsers.
322-
// Requires app-type project (web projects use DOM rendering, not tiles).
322+
// MUST be app-type project — web projects require DOM resources for snapshots
323+
// and reject tile-based uploads. This is an immutable Percy API constraint.
323324

324325
let targetToken: string;
325326
const actualProjectName = args.target_project_name;
326327

327328
if (args.target_token) {
328329
targetToken = args.target_token;
329330
} else {
330-
// Try to get token for existing project first
331+
// Always request app type — tiles only work on app/automate/generic projects.
332+
// If project exists as web-type, this will fail and we retry with a suffix.
331333
try {
332334
targetToken = await getOrCreateProjectToken(
333335
args.target_project_name,
334336
config,
337+
"app",
335338
);
336339
} catch {
337-
// Project doesn't exist — create as app type for tile support
340+
// Project exists as web-type — can't use tiles on it.
341+
// Create companion project with same name + "-screenshots" as app type.
342+
const altName = `${args.target_project_name}-screenshots`;
343+
output += `"${args.target_project_name}" is web-type (needs DOM resources).\n`;
344+
output += `Creating **${altName}** (app-type) for screenshot clone.\n\n`;
338345
try {
339-
targetToken = await getOrCreateProjectToken(
340-
args.target_project_name,
341-
config,
342-
"app",
343-
);
346+
targetToken = await getOrCreateProjectToken(altName, config, "app");
344347
} catch (e: any) {
345348
return {
346349
content: [
347-
{ type: "text", text: `Failed to get project token: ${e.message}` },
350+
{ type: "text", text: `Failed to create project: ${e.message}` },
348351
],
349352
isError: true,
350353
};

0 commit comments

Comments
 (0)