fix: merge .percy.yml config options with snapshot options for serializeDOM#310
fix: merge .percy.yml config options with snapshot options for serializeDOM#310rishigupta1599 wants to merge 5 commits into
Conversation
…izeDOM Config options from .percy.yml (like widths, minHeight, enableJavaScript, etc.) were not being passed to PercyDOM.serialize(). Only per-snapshot options were used. Now merges both, with per-snapshot options taking priority. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…-config-with-serialize-dom
rishigupta1599
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: Failed - see PR comment.
| if (cliConfig != null && cliConfig.has("snapshot") && !cliConfig.isNull("snapshot")) { | ||
| JSONObject snapshotConfig = cliConfig.getJSONObject("snapshot"); | ||
| for (String key : snapshotConfig.keySet()) { | ||
| mergedOptions.put(key, snapshotConfig.get(key)); |
There was a problem hiding this comment.
[Low] Config-supplied widths becomes a JSONArray, not a List
snapshotConfig.get(key) returns org.json native types. A widths array from .percy.yml is copied into mergedOptions as a JSONArray; Java-side consumers that branch on instanceof List would silently ignore it (the serialize/POST new JSONObject(options) path is unaffected).
Suggestion: convert JSONArray values to List when copying, or add a test confirming config-supplied widths flow through.
Reviewer: stack:code-review
Claude Code PR ReviewPR: #310 • Head: 65470c8 • Reviewers: stack:code-review SummaryMerges global Review Table
Findings
Verdict: FAIL — core intent is sound and the diff is small, but the null-clobber in |
rishigupta1599
left a comment
There was a problem hiding this comment.
Claude Code Review (automated) — 1 inline finding(s). Full report in the PR comment below. Verdict: Passed.
| if (cliConfig != null && cliConfig.has("snapshot") && !cliConfig.isNull("snapshot")) { | ||
| JSONObject snapshotConfig = cliConfig.getJSONObject("snapshot"); | ||
| for (String key : snapshotConfig.keySet()) { | ||
| mergedOptions.put(key, snapshotConfig.get(key)); |
There was a problem hiding this comment.
[Medium] Config values land in mergedOptions as raw org.json types
snapshotConfig.get(key) puts JSONObject/JSONArray instances into mergedOptions. buildSnapshotJS re-wraps via new JSONObject(options) so serialization is fine, but extractResponsiveWidths checks instanceof List<?> and resolveReadinessConfig checks instanceof Map — a widths/readiness value sourced from .percy.yml would be a JSONArray/JSONObject and silently miss those branches.
Suggestion: Seed from fully-unwrapped Java types, e.g. mergedOptions.putAll(snapshotConfig.toMap());
Reviewer: stack:code-reviewer
Claude Code PR ReviewPR: #310 • Head: fef3e61 • Reviewers: stack:code-reviewer SummaryFixes a config-clobber bug in Review Table
Findings
Verdict: PASS — The fix correctly resolves the prior null-clobber FAIL and is well-scoped. Remaining findings are Medium/Low latent or pre-existing concerns (missing regression test, |
rishigupta1599
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.
| .thenReturn(new HashMap<String, Object>()); | ||
|
|
||
| // Avoid an actual POST back to the CLI. | ||
| doReturn(new JSONObject()).when(mockedPercy) |
There was a problem hiding this comment.
[Low] POST body not asserted
The request(...) stub uses any(JSONObject.class) and never asserts on the posted payload. This SDK intentionally posts the raw per-call options to the CLI (the documented cross-SDK pattern, with config applied server-side), so this is a coverage observation rather than a defect.
Suggestion: Optional — add an ArgumentCaptor<JSONObject> on request(...) if future behavior ever depends on the posted body. Non-blocking.
Reviewer: stack:code-review
| String jsonArg = serializeScript | ||
| .substring(serializeScript.indexOf('(') + 1, serializeScript.lastIndexOf(')')) | ||
| .trim(); | ||
| JSONObject serialized = new JSONObject(jsonArg); |
There was a problem hiding this comment.
[Low] Fragile serialize-arg extraction
The serialized options are recovered via substring/indexOf string slicing of the JS script. This silently breaks if buildSnapshotJS formatting ever changes (e.g. added comment or multiline output).
Suggestion: Optional — capture/verify the serialized map more directly (e.g. spy on the builder) instead of parsing the script string. Non-blocking.
Reviewer: stack:code-review
Claude Code PR ReviewPR: #310 • Head: ede01f6 • Reviewers: stack:code-review SummaryMerges Review Table
Findings
Verdict: PASS — Merge logic is correct and well-guarded with a focused precedence test; remaining items are Medium/Low and non-blocking (the lone Critical was the intended cross-SDK raw-options POST pattern). |
Claude Code PR ReviewPR: #310 • Head: 449acb4 • Reviewers: stack:code-review SummaryChanges Review Table
FindingsNo blocking findings. The recursive Adjudicated (not a finding, per review instructions): the POST body in Non-blocking: the null-skip branch and array-wholesale-replace branch of Verdict: PASS — correct, focused deep-merge with tests; no new regression. |
Summary
.percy.ymlwere not being passed toPercyDOM.serialize()cliConfig.snapshotinto options Map before callinggetSerializedDOM(), with per-snapshot options taking priorityTest plan
.percy.ymlconfig options are applied during DOM serialization🤖 Generated with Claude Code