Skip to content

fix(context7): bring rules within the schema's 255-char limit - #14

Merged
spencer-zqian merged 2 commits into
mainfrom
fix/context7-rule-length
Jul 24, 2026
Merged

fix(context7): bring rules within the schema's 255-char limit#14
spencer-zqian merged 2 commits into
mainfrom
fix/context7-rule-length

Conversation

@spencer-zqian

Copy link
Copy Markdown
Contributor

Claiming the library failed with:

context7.json format is incorrect for claiming
Requires "url" and "public_key". Known config fields are allowed, but unknown fields are not.

The message points at unknown fields, but that was not it — every top-level key was already allowed. Validating against the published schema found the real cause: rules items are capped at 255 characters, and 5 of the 10 rules exceeded it (longest 488).

Rule Length
2 400
4 488
5 319
6 374
10 268

The parser tolerates oversized values — the repo indexed without complaint — so this stayed invisible until the claim flow, which validates strictly and rejects the whole file.

Fix

Split the over-long rules into shorter ones instead of truncating, so no guidance is lost. 10 → 14 rules, longest now 241 chars, still far under the 50-rule cap.

Added tests covering the schema's limits (per-rule length, rule count, description/title length) and the allowed key set. Verified they fail against the previous file, so they genuinely cover this.

Test plan

  • Full validation against the official schema with jsonschema → passes
  • pytest sonilo-cli → 31 passed (2 new)
  • New tests confirmed to fail on the pre-fix context7.json (5 over-long rules)

Claiming the library unlocks the admin panel, usage metrics, and higher
refresh limits. The claim flow verifies by fetching context7.json from the
default branch, so url and public_key have to live there alongside the
existing parsing config — the claim modal's 'read config from context7.json'
option keeps this file authoritative rather than moving config to the web UI.
Claiming the library failed with "context7.json format is incorrect".
Validating against https://context7.com/schema/context7.json showed 5 of the
10 rules exceeded the 255-character per-rule limit (longest 488).

The parser tolerates oversized values — the repo indexed fine — so nothing
surfaced this until the claim flow, which validates strictly and rejects the
whole file. Split the long rules into shorter ones rather than truncating, so
no guidance is lost; 14 rules now, well under the 50-rule cap.

Adds tests for the schema's limits and the allowed key set, since the failure
mode is silent everywhere except claiming.
@spencer-zqian
spencer-zqian merged commit dbe000c into main Jul 24, 2026
2 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