Skip to content

fix(package): enforce metadata depth before JSON decoding - #94

Merged
AetherAI3 merged 1 commit into
mainfrom
claude/nano-metadata-depth-main
Nov 8, 2026
Merged

AetherAI3 merged 1 commit into
mainfrom
claude/nano-metadata-depth-main

Conversation

@AetherAI3

Copy link
Copy Markdown
Owner

tests/test_package.py::test_metadata_depth_is_positioned fails on Python 3.12+ on main. The nano.json/nano.lock depth budget was enforced only by catching RecursionError from json.loads, and newer CPython decoders accept 2000-deep nesting without recursing — so the documented limit silently disappeared and the required test (3.12)/test (3.13) checks are red on every PR.

  • Scan the raw metadata bytes before decoding (string- and escape-aware) and reject containers deeper than MAX_METADATA_DEPTH (32) with a positioned RESOURCE_LIMIT diagnostic.
  • Valid manifests are a few levels deep, so admitted packages and their hashes are unchanged.
  • New tests: limit vs limit+1 with exact line/column, and brackets inside strings never count.

Local: tests/test_package.py 53 passed (CPython 3.13.5, Windows). Part of #67.

🤖 Generated with Claude Code

The nano.json/nano.lock depth budget was enforced only by catching
RecursionError from json.loads. Python 3.13's decoder accepts 2000-deep
nesting without recursing, so the documented limit silently disappeared
and test_metadata_depth_is_positioned failed on 3.13.

Scan the raw bytes before decoding (string- and escape-aware) and reject
containers deeper than MAX_METADATA_DEPTH (32) with a positioned
RESOURCE_LIMIT diagnostic. Valid manifests are a few levels deep, so
admitted packages and their hashes are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AetherAI3
AetherAI3 merged commit 077aa4a into main Nov 8, 2026
7 checks passed
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.

1 participant