feat(core): upload the snapshot log to the logs endpoint, not as a resource (PPLT-6034) - #2417
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…source (PPLT-6034)
The per-snapshot CLI log was shipped as a `/percy.*.log` snapshot resource,
which the API (PPLT-5969) has to bridge with a Redis hint to route it into
percy-debug-logs. Instead, upload the log directly to POST /api/v1/logs with
service_name='snapshot' and reference_id=<snapshot_id> after the snapshot is
created — the API writes it straight to the log bucket as
{build}_{snapshot}_snapshot_{sha}, with no manifest/redirect dependency.
- @percy/client: add sendSnapshotLog(buildId, snapshotId, content)
- @percy/core discovery: stop pushing the log resource (drop createLogResource)
- @percy/core snapshot: after sendSnapshot, best-effort uploadSnapshotLog using
response.data.id (web snapshots only; automate/app comparisons carry no log)
- update discovery specs that asserted the log resource; add client + core specs
Old CLIs keep sending the log as a resource, so the API's PPLT-5969 redirect
still serves them; the read path already accepts both key shapes.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| // Uploads a single snapshot's CLI log directly to the logs endpoint. The API | ||
| // stores it in the log bucket keyed `{build}_{snapshot}_snapshot_{sha}`, so the | ||
| // log never travels as a snapshot resource (no manifest/redirect dependency). |
There was a problem hiding this comment.
no need for this commits
There was a problem hiding this comment.
Done — removed the comment (the method name + args are self-explanatory).
| // The per-snapshot CLI log is no longer shipped as a resource; it is uploaded | ||
| // directly to the logs endpoint after the snapshot is created (see | ||
| // uploadSnapshotLog in snapshot.js), keyed by the snapshot id. |
There was a problem hiding this comment.
remove this comment
There was a problem hiding this comment.
Done — removed the comment.
| @@ -221,53 +215,19 @@ | |||
There was a problem hiding this comment.
Note:
// The per-snapshot CLI log is no longer shipped as a resource; it is uploaded
// directly to the logs endpoint after the snapshot is created (see
// uploadSnapshotLog in snapshot.js), keyed by the snapshot id.
There was a problem hiding this comment.
Done — removed that comment block; the removal is explained in the commit/PR instead.
| if (send === 'sendSnapshot') { | ||
| yield uploadSnapshotLog(percy, build.id, response.data.id, meta); |
There was a problem hiding this comment.
At this point, does the snapshot is ran, and all the logs are added in the logger ?
There was a problem hiding this comment.
Yes. This runs inside the snapshot upload task, right after sendSnapshot resolves — so asset discovery and snapshot processing are complete and every log entry for this snapshot (matched by meta.snapshot.name + testCase) is already in the logger; logger.query returns them. It's actually a more complete capture than the old approach, which built the log resource during discovery (earlier). Verified live: support:debug on a new-CLI snapshot downloaded the log with 47 real entries.
…d comments
- The log is no longer a resource, so each snapshot uploads one resource (the
DOM). Two `execute`/additionalSnapshots specs indexed resource uploads as
{i*2}/{2} assuming a second (log) resource per snapshot; halve the indices so
they read the right snapshot's DOM (fixes the two @percy/core CI failures).
- Remove the sendSnapshotLog and discovery.js comments per PR review.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…anch coverage Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Resolve discovery.js: drop the log-resource push (log now uploaded via the logs endpoint). Preserve master's secret redaction by moving redactSecrets(logger.snapshotLogs(...)) + evictSnapshot into uploadSnapshotLog. Update merged discovery/snapshot specs (log is no longer a resource).
Code Review — PPLT-6034: snapshot log to dedicated logs endpointSummary: Stops shipping per-snapshot CLI logs as a fake Findings
Checklist result
VerdictApprove — clean, well-scoped, correctly best-effort, and the two subtle correctness risks (build-log starvation via eviction, snapshot-id source) both check out. Only pre-merge ask is the Medium: an explicit redaction test, since this is a new secret-egress path that shouldn't silently regress. 🤖 Repo-specific review via the |
this-is-shivamsingh
left a comment
There was a problem hiding this comment.
Claude Code Review (automated) — 2 inline finding(s). Full report in the PR comment below. Verdict: Passed.
| // snapshots only; automate/app comparisons carry no snapshot log). For | ||
| // sendSnapshot, response.data.id is the snapshot id. Best-effort. | ||
| if (send === 'sendSnapshot') { | ||
| yield uploadSnapshotLog(percy, build.id, response.data.id, meta); |
There was a problem hiding this comment.
[Medium] Snapshot log cache not evicted when the snapshot send fails
logger.evictSnapshot(meta.snapshot) now runs only inside uploadSnapshotLog's finally, which is reached only after let response = yield percy.client[send](build.id, snapshot) (line 533) succeeds. If that send throws, the generator jumps straight to the queue's 'error' handler and this line — and the finally — never run, so the cached log entries for that snapshot key are never evicted (and never sent). Previously evictSnapshot ran unconditionally during discovery, before any upload, so a failed send still evicted. This is a bounded-per-build resource leak on the failure path.
Suggestion: also call logger.evictSnapshot(meta.snapshot) in the queue's 'error' handler, or wrap the client[send] + evict in a try/finally in the task handler so eviction always happens. Add a test for the send-failure path.
Reviewer: stack-code-reviewer
| version: 2 | ||
| snapshots: | ||
| - name: Example Page | ||
| url: https://www.bing.com/ |
There was a problem hiding this comment.
[Medium] Leftover build-test scaffolding, unrelated to PPLT-6034
This file (Example Page → bing.com, Google Homepage → github.com) isn't referenced by any test, script, or package, and its only history is the trailing "percy build testing" commits. It's scratch content used to trigger a Percy build run, not part of the log-upload feature, and should not land on master.
Suggestion: git rm yamls/snapshot.yaml and drop it (plus the three build-test commits) from the PR before merge.
Reviewer: stack-code-reviewer
Claude Code PR ReviewPR: #2417 • Head: 62dbc5d • Reviewers: stack-code-reviewer SummaryMoves the per-snapshot CLI log off the DOM-resource path ( Review Table
Findings
Verified clean (no action needed)
Reconciliation with human reviewers
Verdict: PASS — the endpoint migration is correct and well-tested; no High/Critical findings. Please still address the Medium items before merge: fix (or ticket) the eviction-on-send-failure gap, and strip the stray |
What
The per-snapshot CLI log was shipped as a
/percy.*.logsnapshot resource, which the API (PPLT-5969, percy-api#6761) has to bridge with a Redis hint to route it intopercy-debug-logs. This PR uploads the log directly toPOST /api/v1/logswithservice_name='snapshot'andreference_id=<snapshot_id>right after the snapshot is created — the API writes it straight to the log bucket as{build}_{snapshot}_snapshot_{sha}, with no manifest/redirect dependency.Changes
@percy/client: addsendSnapshotLog(buildId, snapshotId, content)→POST /logswithservice_name: 'snapshot'.@percy/corediscovery: stop pushing the log resource (dropcreateLogResource).@percy/coresnapshot: aftersendSnapshot, best-effortuploadSnapshotLogkeyed byresponse.data.id— web snapshots only (automate/app comparisons carry no snapshot log, and theirresponse.data.idis a comparison id).client+corespecs.Backward compatibility
Old CLIs keep sending the log as a resource, so the API's PPLT-5969 redirect still serves them. The read path (
fetch_cli_snapshot_logs,NetworkLogService.cli_log_file_name, and@percy/cli-supportpercy/percy-cli-support#370) already accepts both key shapes (/percy.*\.log/and_snapshot_). No API change needed; the percy-api Redis-hint cleanup is a follow-up once old CLIs age out.Testing
eslint: clean on all changed files.@percy/clientsuite: passes (new#sendSnapshotLogspecs green).uploadSnapshotLoglogic verified standalone (guard clauses, seed→upload, best-effort). Full core browser suite validated in CI.Related: percy-api PPLT-5969 (#6761), percy/percy-cli-support#370.
🤖 Generated with Claude Code