Skip to content

Handle array-end pointers as CLI resolution errors - #94

Open
Zhuyuyangyy wants to merge 1 commit into
stefankoegl:masterfrom
Zhuyuyangyy:fix-cli-end-of-list
Open

Zhuyuyangyy wants to merge 1 commit into
stefankoegl:masterfrom
Zhuyuyangyy:fix-cli-end-of-list

Conversation

@Zhuyuyangyy

Copy link
Copy Markdown

Problem

Resolving an array-end token (-) through the CLI returns an EndOfList sentinel. Passing that sentinel to json.dumps() raises an uncaught TypeError, prints a traceback, and prevents subsequent files from being processed.

For example:

printf "[1, 2]" | jsonpointer /- -

Change

Handle EndOfList as a normal resolution failure in the CLI, using the existing error-reporting and nonzero-exit path. The Python API and its sentinel behavior are unchanged. An object member named - still resolves normally.

Tests

Added regression coverage for empty and nonempty arrays, nested arrays, batches with the failing file before or after a successful file, and valid object members named -.

Before the fix, the two new error-handling tests fail (five failing subtests). After the fix:

python -m unittest
Ran 70 tests
OK

This contribution was prepared with AI assistance; the reproduction and tests above were run against the checked-out code.

Copilot AI left a comment

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.

🟢 Approval recommended

The focused CLI guard uses the existing error path, preserves API behavior, and has regression coverage for the affected cases.

No open issues 🎉

What changed in this PR

This PR handles array-end pointers as normal CLI resolution errors instead of allowing an uncaught serialization error. The Python API’s sentinel behavior remains unchanged.

Changes:

  • Routes EndOfList results through the existing error-reporting and nonzero-exit path.
  • Adds regression tests for empty and nonempty arrays, nested arrays, continued batch processing, and valid object members named -.
File Description
tests.py Adds regression coverage for array-end errors and valid hyphen keys.
bin/​jsonpointer Rejects EndOfList results before JSON serialization.

Review effort: Balanced

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 97.714%. remained the same — Zhuyuyangyy:fix-cli-end-of-list into stefankoegl:master

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.

3 participants