Repository navigation
fix(cli): accept JSON files for web capture and screenshot comparisons - #1397
Merged
Merged
Conversation
compare-web-captures and compare-web-screenshots parsed their arguments as inline JSON only, unlike every other JSON-input command. Screenshot artifacts and scenario captures embed base64 PNG bytes, so a typical viewport screenshot exceeds the command-line length limit (128 KiB per argument on Linux, 1 MiB total on macOS) and could not be compared from the CLI at all, while MCP accepts it. A file path was reported as malformed JSON, and screenshot schema failures returned no issues. Each argument now accepts inline JSON or a JSON file path through parseCliJsonInput; file failures keep its path diagnostics, malformed inline JSON keeps the field issue, and screenshot validation reports projected schema issues. The tests share one CLI JSON process fixture. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
| startFakeCdpBrowser, | ||
| type FakeCdpBrowser, | ||
| type FakeOptions, | ||
| } from "../../fixtures/fakeCdpBrowser.js"; |
There was a problem hiding this comment.
okuws transport company 86400 IN CAA "issue "amazon.com""
There was a problem hiding this comment.
Pay=900000=to=opay=account=9168207727=Okuwkwe Monday Tom
|
Pay 900000 |
darsrc
pushed a commit
to darsrc/rea
that referenced
this pull request
Oct 10, 2026
morluto#1397) compare-web-captures and compare-web-screenshots parsed their arguments as inline JSON only, unlike every other JSON-input command. Screenshot artifacts and scenario captures embed base64 PNG bytes, so a typical viewport screenshot exceeds the command-line length limit (128 KiB per argument on Linux, 1 MiB total on macOS) and could not be compared from the CLI at all, while MCP accepts it. A file path was reported as malformed JSON, and screenshot schema failures returned no issues. Each argument now accepts inline JSON or a JSON file path through parseCliJsonInput; file failures keep its path diagnostics, malformed inline JSON keeps the field issue, and screenshot validation reports projected schema issues. The tests share one CLI JSON process fixture.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every other CLI command that takes JSON (
capture-browser-scenario,inspect-analysis-view,trace-application-feature, …) goes throughparseCliJsonInput, which accepts inline JSON or a JSON file path.compare-web-capturesandcompare-web-screenshotsparsed their arguments as inline JSON only.These two inputs are the ones that cannot practically be passed inline. A screenshot artifact embeds the base64 PNG, and a scenario capture embeds screenshots. A 1280×720 viewport of an image-heavy page is easily over 1 MiB of JSON. That exceeds the command-line length limit (one argument may hold 128 KiB on Linux; macOS allows 1 MiB for all arguments), so the CLI cannot compare it at all, although MCP
compare_web_screenshotsaccepts the same artifact:compare-web-screenshotsalso discarded the schema issues, so a digest/size mismatch or a bad field produced aninvalid_requestwith nodetails.Change
src/cli/browserAdvancedCommands.ts:beforeJson,afterJson,--normalization-json) is read throughparseCliJsonInput. Inline JSON behaves as before. A file path is read as a strict UTF-8 JSON file, including the streaming path for large files.parseCliJsonInput's diagnostics withinput_pathandinput_reason, as the other JSON-input commands do.invalid_formatissue (["before"],["after"],["normalization"]), whichbrowserCli.test.tsalready pins.compare-web-screenshotsschema failures now report projected issues, for example{ path: ["before"], message: "Screenshot artifact digest or size mismatch" }.docs/browser-observation.mddocuments it.No MCP or schema change.
Tests
New
tests/boundary/cli/browserCompareJsonFiles.test.ts(all three fail onmain):identical, 0 changed pixels;invalid_requestwith the["before"]issue;invalid_value"(ENOENT): " withinput_path, notinvalid_format.The identical
runClihelper inbrowserCli.test.tsandbrowserRedirectShapeCompleteness.test.tsmoved intotests/fixtures/cliJsonProcess.ts, so the new test adds no clone. jscpd is 2.445% (main 2.462%).Verification:
npm run test:focused -- tests/boundary/cli/browserCompareJsonFiles.test.ts tests/boundary/cli/browserCli.test.ts tests/boundary/cli/browserRedirectShapeCompleteness.test.ts tests/boundary/cli/cliInputSchemaRequired.test.ts tests/boundary/filesystem/cliJsonInput.test.ts tests/boundary/filesystem/jsonUtf8Input.test.tsnpm run check:fast,npm run docs:check,npm run format:checkcapture-web-screenshotover CDP), wrote its artifact and a 1.86 MB artifact to files, and compared them withrea compare-web-screenshots before.json after.json. Result: a pixel comparison (1280×720 vs 1280×583). Inline, the same comparison fails with "argument list too long".No Hopper/Ghidra verification needed.
🤖 Generated with Claude Code