Skip to content

Continue CLI batches after malformed JSON input - #92

Open
xingzhao-ji wants to merge 2 commits into
stefankoegl:masterfrom
xingzhao-ji:fix-cli-malformed-json-batches
Open

xingzhao-ji wants to merge 2 commits into
stefankoegl:masterfrom
xingzhao-ji:fix-cli-malformed-json-batches

Conversation

@xingzhao-ji

@xingzhao-ji xingzhao-ji commented Oct 12, 2026 •

Copy link
Copy Markdown

Malformed JSON or invalid text encoding currently stops CLI batches before later files are processed. This adds --continue-on-error to report those failures and continue with the remaining files while preserving the default behavior and returning exit status 1. Regression tests cover malformed JSON and invalid encoding, default stopping behavior, valid inputs, and missing-file errors.

@coveralls

coveralls commented Oct 12, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 97.917%. remained the same — xingzhao-ji:fix-cli-malformed-json-batches into stefankoegl:master

@stefankoegl

Copy link
Copy Markdown
Owner

Thanks for your contribution! Somehow I have the feeling that this behavior should be optional. What do you think about a --continue-on-error flag that controls it?

@Wkhanex Wkhanex left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The mixed-batch fix works for malformed JSON: I ran the real PR CLI with an invalid file at the beginning, middle and end of two valid files; all three runs retained both valid outputs and exited 1 without a traceback. A remaining adjacent malformed-input case still aborts the batch: a file containing bytes b'{"a":"\xff"}' raises UnicodeDecodeError, and the following valid file is never processed. Consider handling UnicodeDecodeError alongside JSONDecodeError, with the same file-labelled diagnostic and continuation behavior. I ran these checks on Python 3.12; real CLI subprocesses used only synthetic temporary files.

@xingzhao-ji
xingzhao-ji force-pushed the fix-cli-malformed-json-batches branch from a2b4848 to 15079d6 Compare October 13, 2026 20:24
@xingzhao-ji
xingzhao-ji marked this pull request as ready for review October 14, 2026 17:54

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants