Skip to content

fix(client): accept diffSensitivity 0-4 (Very Strict) in PERCY_VISUAL_CONFIG - #2453

Merged
rishigupta1599 merged 2 commits into
masterfrom
fix/PER-10796-visual-config-diff-sensitivity-zero
Oct 6, 2026
Merged

rishigupta1599 merged 2 commits into
masterfrom
fix/PER-10796-visual-config-diff-sensitivity-zero

Conversation

@rishigupta1599

@rishigupta1599 rishigupta1599 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Fixes PER-10796

Root cause

packages/client/src/client.js:137 validates PERCY_VISUAL_CONFIG.diffSensitivity as an integer 1–5. The API does not remap it: Build#settings (percy-api app/models/percy/build.rb:531) passes it through untouched, and CompareJobService.fetch_fuzz_factor (lib/percy/compare_job_service.rb:510-511) returns it as the fuzz level, overriding the project setting. That index is 0-based, the same scale as Project.diff_sensitivity_level (very_strict: 0 … very_relaxed: 4) and the snapshot diffSensitivity schema in packages/core/src/config.js:70 (0–4).

So:

  • Very Strict (0) can't be requested. The CLI throws 'diffSensitivity' must be an integer between 1 and 5, so Percy is disabled for the run.
  • 1 is quietly Strict, not "most strict". It also overrides a project that is already set to Very Strict. In PER-10796, build 54272606 (project 465815, project level = 0) carried visual_config {"diffSensitivity": 1}, compared at Strict, and missed a #FDDFC3 → #FCEAC0 toggle change (max per-channel delta 11, which is under Strict's threshold of 15).

Fix

Lower bound 1 → 0. I kept the upper bound at 5 so nobody who passes 5 today gets a failing build. Fuzz index 5 is valid in the differ; it's what the app-percy iPhone path uses.

Testing

  • New: diffSensitivity: 0 is accepted and forwarded as visual-config.
  • New: -1 is rejected.
  • Updated: the error-message assertion.
  • CI runs the suite.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Corrected visual configuration validation for diffSensitivity: integer values from 0 through 4 are accepted, including 0, and values outside that range or non-integer values are rejected. The setting uses a zero-indexed scale, where 0 is Very Strict and 4 is Very Relaxed.

The API passes visual-config.diffSensitivity straight through as the
0-indexed fuzz level (0 = Very Strict, matching the project enum and the
snapshot diffSensitivity schema). The 1..5 range made Very Strict
unreachable and silently turned "1" into Strict.

Fixes PER-10796

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@rishigupta1599
rishigupta1599 requested a review from a team as a code owner October 6, 2026 13:10
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited), Workspace UI (inherited)
  • Review profile: ASSERTIVE
  • Plan: Enterprise
  • Run ID: 53738e8e-8734-4a5c-9171-e7bfd98660d8
📥 Commits

Reviewing files that changed from the base of the PR and between dfe1045 and 1411b97.

📒 Files selected for processing (2)
  • packages/client/src/client.js
  • packages/client/test/client.test.js
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 7 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (7)
  • GitHub Check: Typecheck
  • GitHub Check: Build
  • GitHub Check: Build
  • GitHub Check: semgrep/ci
  • GitHub Check: Lint
  • GitHub Check: Analyze (actions)
  • GitHub Check: Analyze (javascript-typescript)
🧰 Additional context used
📚 Code guidelines (8)
8 cross-repository guideline sources
📓 Path-based instructions (8)
Source excerpt: **`PERCY_TOKEN`** — read only from env vars or explicit flags; never log it, never write it to `package.json`, `.percy.yml`, or any committed file.

📄 CodeRabbit inference engine (percy/browserstack-ai-harness-percy:stacks/stack-domain-percy-cli/rules/security.md)

Files:

  • packages/client/src/client.js
  • packages/client/test/client.test.js
Source excerpt: Read `../rules/security.md` first.

📄 CodeRabbit inference engine (percy/browserstack-ai-harness-percy:stacks/stack-domain-percy-cli/knowledge/DEPENDENCIES.md)

Files:

  • packages/client/src/client.js
  • packages/client/test/client.test.js
Source excerpt: GraalJS scripts must not use Node globals.

📄 CodeRabbit inference engine (percy/browserstack-ai-harness-percy:stacks/stack-domain-percy-app-sdk/agents/stack-percy-app-sdk-code-reviewer.md)

Files:

  • packages/client/src/client.js
  • packages/client/test/client.test.js
Source excerpt: Match the dominant style for the area you're touching.

📄 CodeRabbit inference engine (percy/browserstack-ai-harness-percy:stacks/stack-domain-percy-cli/rules/commit-conventions.md)

Files:

  • packages/client/src/client.js
  • packages/client/test/client.test.js
Source excerpt: Known user-facing errors, their meaning, and remediation.

📄 CodeRabbit inference engine (percy/browserstack-ai-harness-percy:stacks/stack-domain-percy-cli/knowledge/ERROR-CATALOG.md)

Files:

  • packages/client/src/client.js
  • packages/client/test/client.test.js
Source excerpt: | Symptom | Cause | |---|---| | Tests pass but exit hangs | Asset discovery did not finish; raise `discovery.networkIdleTimeout` in `.percy.yml`.

📄 CodeRabbit inference engine (percy/browserstack-ai-harness-percy:stacks/stack-domain-percy-web-sdks/knowledge/flow-percy-exec-lifecycle.md)

Files:

  • packages/client/src/client.js
  • packages/client/test/client.test.js
Source excerpt: Healthcheck (same as web SDKs).

📄 CodeRabbit inference engine (percy/browserstack-ai-harness-percy:stacks/stack-domain-percy-web-sdks/knowledge/flow-snapshot-appium.md)

Files:

  • packages/client/src/client.js
  • packages/client/test/client.test.js
Source excerpt: Add an entry to this file.

📄 CodeRabbit inference engine (percy/browserstack-ai-harness-percy:stacks/stack-domain-percy-web-sdks/knowledge/FEATURE-FLAGS.md)

Files:

  • packages/client/src/client.js
  • packages/client/test/client.test.js
🔇 Additional comments (1)
packages/client/src/client.js (1)

138-138: 🗄️ Data Integrity & Integration

The repository does not establish that app-percy supplies diffSensitivity: 5.

packages/client/src/client.js validates diffSensitivity from PERCY_VISUAL_CONFIG as an integer from 0 through 4. The repository schema also defines the range as 0 through 4. No app-percy producer or contract for value 5 is present in the inspected repository.

The request to change the maximum to 5, and to update the test accordingly, is therefore unsupported by the available source.


📝 Walkthrough

Walkthrough

The client rejected diffSensitivity: 0 and used a 1–5 range. It now accepts integer values from 0 through 4. Tests cover acceptance of 0 and rejection of a string and 5.

Changes

diffSensitivity validation

Layer / File(s) Summary
Validate diffSensitivity range
packages/client/src/client.js, packages/client/test/client.test.js
The validation range changes from 1–5 to 0–4. Tests verify that 0 is accepted and forwarded, and that a string and 5 are rejected with the updated range error.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 1411b

The client now accepts 0 and caps the setting at 4, matching the shared schema. No actionable supported-path risk is established, so the change appears ready for normal checks.

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title describes the change, but it does not include the required Jira ticket ID. Add the related ticket ID, such as PER-10796, to the title while keeping its plain-English description.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
  • Fix all pre-merge checks with AI
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

Match Project.diff_sensitivity_level and the snapshot diffSensitivity
schema. Index 5 in the differ is an internal app-percy value with the
same threshold (60) as 4.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@rishigupta1599 rishigupta1599 changed the title fix(client): allow diffSensitivity 0 (Very Strict) in PERCY_VISUAL_CONFIG fix(client): accept diffSensitivity 0-4 (Very Strict) in PERCY_VISUAL_CONFIG Oct 6, 2026
@rishigupta1599
rishigupta1599 merged commit aa27aed into master Oct 6, 2026
50 of 51 checks passed
@rishigupta1599
rishigupta1599 deleted the fix/PER-10796-visual-config-diff-sensitivity-zero branch October 6, 2026 13:38
@rishigupta1599 rishigupta1599 added the 🐛 bug Something isn't working label Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants