Skip to content

fix: merge .percy.yml config options into serializeDOM - #754

Open
rishigupta1599 wants to merge 6 commits into
masterfrom
fix/merge-percy-yml-config-with-serialize-dom
Open

fix: merge .percy.yml config options into serializeDOM#754
rishigupta1599 wants to merge 6 commits into
masterfrom
fix/merge-percy-yml-config-with-serialize-dom

Conversation

@rishigupta1599

Copy link
Copy Markdown

Summary

  • .percy.yml config options were not being passed to PercyDOM.serialize() — only per-snapshot options were used
  • Now merges utils.percy.config.snapshot as defaults with per-snapshot options taking priority

Test plan

  • Verify existing tests pass

🤖 Generated with Claude Code

…izeDOM

Previously, only per-snapshot options were passed to PercyDOM.serialize(),
ignoring config-level settings (enableJavaScript, disableShadowDOM, etc.)
from .percy.yml. Now config.snapshot is used as defaults, with per-snapshot
options taking priority.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rishigupta1599
rishigupta1599 requested a review from a team as a code owner May 5, 2026 18:40
Replace inline config merge with centralized utility from sdk-utils.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for more than 14 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions Bot added the 🍞 stale Closed due to inactivity label May 19, 2026
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

This PR was closed because it has been stalled for 28 days with no activity.

@github-actions github-actions Bot closed this Jun 2, 2026

@rishigupta1599 rishigupta1599 left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review (automated) — 1 inline finding(s). Full report in the PR comment below. Verdict: Passed.

Comment thread index.js
await nEval(new Function(await utils.fetchPercyDOM()));

// Serialize and capture the DOM
const mergedOptions = utils.mergeSnapshotOptions(options);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Medium] mergeSnapshotOptions requires a newer @percy/sdk-utils than the pinned range

utils.mergeSnapshotOptions was only added to @percy/sdk-utils in 1.32.0-beta.9, but package.json pins @percy/sdk-utils: ^1.0.0. An environment resolving an older 1.x sdk-utils satisfies the range yet lacks this export, so this line throws TypeError: utils.mergeSnapshotOptions is not a function and the snapshot is silently swallowed by the surrounding catch.

Suggestion: Bump the minimum @percy/sdk-utils to the version that ships mergeSnapshotOptions (e.g. ^1.32.0), or guard the call: const mergedOptions = utils.mergeSnapshotOptions?.(options) ?? options;

Reviewer: stack:code-review

@rishigupta1599

Copy link
Copy Markdown
Author

Claude Code PR Review

PR: #754Head: ca9b0cbReviewers: stack:code-review

Summary

Merges the global .percy.yml snapshot config (utils.percy.config.snapshot) with per-snapshot options (per-call priority) into mergedOptions and passes that to PercyDOM.serialize() before serializing the DOM, so config-level snapshot options now reach serialization in the Nightmare SDK (PER-8053).

Review Table

Priority Category Check Status Notes
High Security No hardcoded secrets or credentials N/A Security lens skipped per instruction; no secrets in diff.
High Security Authentication/authorization checks present N/A Security lens skipped; no auth surface touched.
High Security Input validation and sanitization N/A Security lens skipped.
High Security No IDOR — resource ownership validated N/A Security lens skipped.
High Security No SQL injection (parameterized queries) N/A Security lens skipped; no DB access.
High Correctness Logic is correct, handles edge cases Pass mergeSnapshotOptions (sdk-utils) is a shallow merge {...configOptions, ...options} with per-call priority; handles undefined options. Matches PR intent.
High Correctness Error handling is explicit, no swallowed exceptions Pass Call sits inside the existing try/catch (index.js:48); no new error paths introduced.
High Correctness No race conditions or concurrency issues Pass Pure synchronous transform of options; no shared state or new async.
Medium Testing New code has corresponding tests Fail No test in test/index.test.js asserts config options are merged into the serialized options; new behavior is unverified in this repo (test/index.test.js).
Medium Testing Error paths and edge cases tested N/A No new error path added by this change.
Medium Testing Existing tests still pass (no regressions) Pass Change is additive; serialize call still receives an options object. The serialize injection is istanbul ignored so coverage is unaffected.
Medium Performance No N+1 queries or unbounded data fetching Pass No I/O; single in-memory object spread.
Medium Performance Long-running tasks use background jobs N/A Not applicable to an SDK snapshot call.
Medium Quality Follows existing codebase patterns Pass Mirrors percy-puppeteer/percy-playwright/percy-selenium-js exactly: mergedOptions→serialize, raw ...options→postSnapshot.
Medium Quality Changes are focused (single concern) Pass One-line addition + one substitution; single concern.
Low Quality Meaningful names, no dead code Pass mergedOptions is clear and used immediately.
Low Quality Comments explain why, not what Pass Existing comments unchanged; no misleading comments added.
Low Quality No unnecessary dependencies added Fail mergeSnapshotOptions only exists in @percy/sdk-utils >= 1.32.0-beta.9, but package.json pins @percy/sdk-utils: ^1.0.0. An installed older 1.x satisfies the range yet lacks the function → utils.mergeSnapshotOptions is not a function TypeError at runtime.

Findings

  • File: package.json (dependency @percy/sdk-utils)

  • Severity: Medium

  • Reviewer: stack:code-review

  • Issue: The change calls utils.mergeSnapshotOptions(options), but that export was only added to @percy/sdk-utils in 1.32.0-beta.9. The dependency range is ^1.0.0, so an environment that resolves any older 1.x sdk-utils will throw TypeError: utils.mergeSnapshotOptions is not a function and the snapshot will be swallowed by the catch block, silently losing the snapshot.

  • Suggestion: Bump the minimum @percy/sdk-utils to the version that ships mergeSnapshotOptions (e.g. ^1.32.0), consistent with the other SDKs adopting this helper, or guard the call ((utils.mergeSnapshotOptions?.(options)) ?? options).

  • File: test/index.test.js

  • Severity: Low

  • Reviewer: stack:code-review

  • Issue: No test verifies the new merge behavior — that .percy.yml config snapshot options are applied to serialization with per-call options winning. The serialize injection is istanbul ignored, so the merge path is entirely unverified in this repo.

  • Suggestion: Add a test that sets percy.config.snapshot (or stubs utils.mergeSnapshotOptions) and asserts merged options reach the serialize call, mirroring coverage added in sibling SDKs.


Verdict: PASS — correct, minimal, and consistent with sibling SDKs; recommend bumping the @percy/sdk-utils minimum version and adding a merge-behavior test before release.

@github-actions github-actions Bot removed the 🍞 stale Closed due to inactivity label Jun 16, 2026
rishigupta1599 and others added 2 commits June 17, 2026 16:53
This SDK has no committed lockfile, so CI's bare `yarn` resolves dependencies
fresh to the latest versions each run. Via @percy/core, that now pulls
node-releases@2.0.47 (node>=18, through nyc->babel->browserslist) and
snyk-nodejs-lockfile-parser@2.7.1 (node>=18, which also drags in @yarnpkg/core@4
+ tar@7) — and yarn hard-fails on the engine mismatch, breaking the Node 14 leg
on install.

Pin both back to their last Node-14-compatible line via resolutions (yarn
honors these on the fresh install); the snyk pin also drops the @yarnpkg/tar@7
subtree. Temporary workaround pending the upstream CLI fix (percy/cli#2301).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment thread yarn.lock
Comment on lines -1 to -3
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this removed?

Comment thread index.js
domSnapshot: PercyDOM.serialize(options),
url: document.URL
}), options);
}), mergedOptions);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No test coverage for this? is it covered in the existing UTs?

rishigupta1599 and others added 2 commits July 10, 2026 16:04
Commit 639b9ec ("regen lockfile") accidentally *deleted* yarn.lock entirely
instead of regenerating it, leaving the SDK with no committed lockfile. Restore
it from base and regenerate against the current package.json (@percy deps +
node-14 resolutions) so there is a proper, consistent, committed lockfile again.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Restoring/regenerating the lockfile pulled event-loop-spinner@2.3.3 (node>=18)
via snyk-nodejs-lockfile-parser -> @snyk/dep-graph, breaking the Node 14 lint/
typecheck legs. Pin to 2.3.2 (last node-14-compatible line) alongside the other
transitive pins.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for more than 14 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions Bot added the 🍞 stale Closed due to inactivity label Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🍞 stale Closed due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants