Skip to content

fix(preprod): Use odiff CLI mode to work around server-mode false match bug#112829

Merged
NicoHinderling merged 1 commit into
masterfrom
nico/odiff-cli-workaround
Apr 13, 2026
Merged

fix(preprod): Use odiff CLI mode to work around server-mode false match bug#112829
NicoHinderling merged 1 commit into
masterfrom
nico/odiff-cli-workaround

Conversation

@NicoHinderling
Copy link
Copy Markdown
Contributor

Switch snapshot image comparison from odiff server mode to CLI mode
(one subprocess per comparison) to work around a non-deterministic
false match bug caused by stdin buffer reuse in server mode.

The upstream fix is at dmtrKovalenko/odiff#170.
All server-mode code is commented out (not deleted) for easy revert
once the fix is released in odiff-bin.

Also changes pixel counting from parsing odiff stdout (which varied
across versions) to counting non-zero pixels from the diff mask via
PIL histogram — more reliable and version-independent.

…ch bug

odiff server mode has a stdin buffer reuse bug that causes
non-deterministic false match=True results. Switch to CLI mode
(one subprocess per comparison) until the upstream fix lands.

All server-mode code is commented out for easy revert once
dmtrKovalenko/odiff#170 is released
in odiff-bin.

Also derives changed pixel count from the diff mask histogram
instead of parsing odiff stdout, which is more reliable.
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 13, 2026
@NicoHinderling NicoHinderling marked this pull request as ready for review April 13, 2026 18:30
@NicoHinderling NicoHinderling requested a review from a team as a code owner April 13, 2026 18:30
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d075061. Configure here.


_CLI_FLAG_MAP = {
"outputDiffMask": "diff-mask",
}
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.

Incorrect CLI flag name mapping for diff mask

High Severity

The _CLI_FLAG_MAP maps "outputDiffMask" to "diff-mask", producing CLI flag --diff-mask. The actual odiff CLI flag is --output-diff-mask. The standard camelCase-to-kebab-case conversion of outputDiffMask yields output-diff-mask, but the map incorrectly drops the output- prefix. This causes odiff to receive an unrecognized flag, likely making every comparison fail with a RuntimeError (non-zero exit code not in the allowed set {0, 21, 22}).

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d075061. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

wrong, i intentionally changed this (and verified this is the correct setup)

@NicoHinderling NicoHinderling merged commit 53eee53 into master Apr 13, 2026
57 checks passed
@NicoHinderling NicoHinderling deleted the nico/odiff-cli-workaround branch April 13, 2026 18:48
wedamija pushed a commit that referenced this pull request Apr 13, 2026
…ch bug (#112829)

Switch snapshot image comparison from odiff server mode to CLI mode
(one subprocess per comparison) to work around a non-deterministic
false match bug caused by stdin buffer reuse in server mode.

The upstream fix is at dmtrKovalenko/odiff#170.
All server-mode code is commented out (not deleted) for easy revert
once the fix is released in odiff-bin.

Also changes pixel counting from parsing odiff stdout (which varied
across versions) to counting non-zero pixels from the diff mask via
PIL histogram — more reliable and version-independent.
NicoHinderling added a commit that referenced this pull request Apr 17, 2026
odiff-bin v4.3.8 ships the upstream fix for the server-mode stdin buffer
reuse bug (dmtrKovalenko/odiff#170), so we can
drop the CLI-mode fallback introduced in #112829 and go back to using
server mode.

Also:
- Pin odiff-bin to exact 4.3.8 (no caret) in package.json and CI
- Point _find_odiff_binary() at node_modules/odiff-bin/bin/odiff.exe;
  v4.3.8's post-install only chmods this path, while raw_binaries/ ship
  without the execute bit
- Extract _fetch_batch_images helper in tasks.py to avoid per-iteration
  closure rebinding inside the batch loop

Co-Authored-By: Claude <noreply@anthropic.com>
NicoHinderling added a commit that referenced this pull request Apr 20, 2026
)

Reverts the odiff CLI-mode workaround (#112829) now that odiff-bin
v4.3.8 ships the upstream fix for the server-mode stdin buffer reuse bug
([dmtrKovalenko/odiff#170](dmtrKovalenko/odiff#170)).
Snapshot comparison goes back to using server mode — one persistent
subprocess per batch instead of spawning one per comparison.

### Dependency pin

`odiff-bin` is pinned to exact `4.3.8` (no caret) in `package.json`,
`pnpm-lock.yaml`, and the CI workflow. Exact pin keeps dev / prod / CI
in lockstep with minimal machinery.

### Bonus fix — binary resolution

`_find_odiff_binary()` now points at
`node_modules/odiff-bin/bin/odiff.exe` instead of
`raw_binaries/odiff-<platform>`. v4.3.8's `post_install.js` only sets
the execute bit on `bin/odiff.exe`; the raw binaries ship without `+x`,
which was causing `PermissionError` on fresh installs. Despite the
`.exe` suffix, this is the package's cross-platform entrypoint on all
OSes.

### Minor cleanup

Extracted `_fetch_batch_images` helper in `tasks.py` so the per-batch
closure / lock / cache setup lives in one place instead of being rebuilt
inside every loop iteration.

Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants