Repository navigation
fix: read deeply nested JSON-LD without recursion - #394
Conversation
article_reader walked JSON-LD metadata and author names recursively, so a block nested past the interpreter's depth limit raised RecursionError even when json.loads() accepted it, and json.loads() itself raises RecursionError rather than ValueError on very deep input. Both walks now use an explicit stack, and decoding treats RecursionError as unreadable metadata, so the page title and paragraphs still come through. Closes Vycari#388 Signed-off-by: Niladri Das <125604915+bniladridas@users.noreply.github.com>
Vycari ReviewRound 1 on faa969f. The verdict is the Vycari Review check run, and each open finding is an inline thread. Reply on every P0 and P1 thread: Open: P0 0 · P1 0 · P2 0 · disputed 0 · confirmed fixed 0 · withdrawn 0 Hand-off: Greptile requested on faa969f. No open findings this round. P2s, judge's notes and closed findingsJudge's notes No candidate findings were raised. |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@greptileai review |
allenhutchison
left a comment
There was a problem hiding this comment.
Thanks for the fix!
Human overview
pepper feed show N --readcould fail a whole read when a page's JSON-LD metadata was nested deeply: the stdlib JSON decoder, and the recursive walk over the decoded block, both raiseRecursionError, which the code did not catch. Decoding and traversing now treat that as unreadable metadata, so the page's title and paragraphs still render. Fixes #388.AI reviewer
Details for agents: what the diff does, invariants, verification, checklist
What the diff does
src/pepper_cli/article_reader.py:_walk()now iterates with an explicit stack instead of recursing. Dict values and list items are pushed reversed so the pop order matches the old traversal, which means a page with several matches still yields the same first value under a key._name()is iterative too. Author values can nest as deeply as the rest of the block ({"author": {"name": {"name": ...}}}), and the old version could raiseRecursionErrorfrom a second recursive path that the decoder exception never covered. It still follows only thenamekey on dicts and joins list entries with", "in order.parse()now catchesRecursionErroralongsideValueErroraroundjson.loads(). A block that cannot be decoded is skipped, and later blocks still contribute metadata.Tests in
tests/test_article_reader.pycover a 1500-deep valid block whose author is found, a 1500-deep author name, a 10,000-deep array thatjson.loads()rejects withRecursionError, and a malformed deep block followed by a normal one. Each asserts the readable title and paragraphs survive.Invariants: JSON-LD stays best-effort metadata. A page whose metadata is unusable still returns its title and paragraphs, and one bad block never suppresses another. No network, credential, or wire-contract code is touched, so the private-address guard, byte cap, and deadline are unchanged.
Alternatives rejected: a depth counter would still need an arbitrary limit and would drop metadata that the iterative walk reads for free. Raising the interpreter recursion limit is process-global and unsafe in a long-lived TUI process.
Failure posture: if the traversal order were wrong, metadata could pick a different author or date on a page with several matches, which only affects display. If
RecursionErrorescaped again, the read would fail instead of degrading, which is the reported bug.Look hardest at
_name(): the old dict branch read onlyname, and the new stack must keep that plus list order and the dropping of empty strings.Verification, exactly as run:
uv run pytest -q tests/test_article_reader.py: 37 passeduv run pytest -n auto -q: 4214 passed, 21 skipped in 201.55suv run pytest -n auto --cov --cov-report=json:coverage-summary.json: 4214 passed, 21 skipped in 346.02s; coverage 95.54% (17725/18552), floor 88uv run ruff format --check: 175 files already formatteduv run ruff check: All checks passeduv run ty check src/pepper_cli/: All checks passedgit diff --check: clean, and no em or en dashes in the changed files or the commit messagearticle_reader.py, where they fail withRecursionErrorfrom the old recursive_walk()and_name()Deferred work: none.
Checklist (repo-specific)
uv run ruff format --checkanduv run ruff checkclean (no new lint ignores)uv run ty check src/pepper_cli/cleanuv run pytestpasses; coverage floor in.claude/maintainerd.jsonnot loweredSKILL.mdupdated if commands or output changed: not applicable, neither changedhelp/cli.mdupdated for a new or changed command, or not user-facing because the output for a readable page is unchanged

Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
The PR keeps deeply nested JSON-LD from breaking article reads.
Reviews (1) · Last reviewed commit: "fix: read deeply nested JSON-LD without ..." · Reviewed by Greptile