Skip to content

Handle the submission queue and upload size limit; add tests and CI - #1

Merged
saalse merged 3 commits into
mainfrom
fix/add-queue-and-upload-size
Nov 22, 2026
Merged

saalse merged 3 commits into
mainfrom
fix/add-queue-and-upload-size

Conversation

@saalse

@saalse saalse commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

Two limits of the Context7 API made c7.py awkward in real use:

  • Submission queue: Context7 accepts at most 5 libraries processing or queued per user. A sixth add got 400 user-has-active-task, which c7.py reported as bad input (exit 2), so agents wrote their own retry loops.
  • Upload size: uploads over about 4.5 MB get 413 FUNCTION_PAYLOAD_TOO_LARGE. This wasn't documented, and the error came back as a generic API failure.

add

  • Takes several URLs and validates all of them before sending any.
  • Stops on a full queue (exit 9), a 429 (exit 6) or a 401 (exit 3), and lists the inputs still to send in notSubmitted. Other refusals and network errors go in failed.
  • --queue waits for a free slot (30 s polls, --queue-timeout per URL), so one call can submit a whole list.
  • Prints one progress line per URL. Ctrl-C or SIGTERM prints the partial summary and exits 130.
  • Sends a git token only with repositories, never with websites.

upload

  • Refuses files over 4.4 MB before sending, with a split hint for the file type (qpdf for PDFs). --skip-size-check overrides that.
  • Says that the library id comes from the file name, not from --title.

Also

  • Network failures come back as JSON instead of a traceback.
  • Every command has --help text.
  • log keeps stdout JSON.
  • The skill and plugin are at version 1.2.
  • Docs: a new Upload a file page, an Add many sources section, new gotchas and exit codes. Examples use this repo where a real source fits.

Tests, CI, badges

  • tests/test_c7.py: 58 offline tests with the API stubbed, so they need no key or network.
  • .github/workflows/ci.yml:
    • runs the tests on Python 3.8 to 3.14 on ubuntu-24.04;
    • runs a syntax check and validates the skill against the Agent Skills specification;
    • writes a coverage report to the job summary.
  • README: CI, Python, license, last-commit, Agent Skills and Context7 badges.
  • context7.json keeps tests/ and .github/ out of the Context7 index.

Testing

  • The offline suite passes locally on Python 3.9, 3.12, 3.13, 3.14 and 3.15. This PR's CI run covers 3.8, 3.10 and 3.11.
  • End to end against the live API:
    • whoami and check work;
    • an add of already-indexed sources, one at a time and several at once, creates nothing and exits 0;
    • a real PDF upload goes through, indexes and answers a query;
    • a 4.6 MB file gets 413 from Context7 when forced past the check, and is refused locally (exit 2) without it.
  • Not tested live: the queue-full path, which would need 5 real public submissions, and signals. The stubbed tests cover both, along with a real SIGTERM sent to the test process.
  • Six independent code reviews. The versions of the CI actions, setup-python's builds per Ubuntu image, and coverage were checked through Context7.

🤖 Generated with Claude Code

saalse and others added 3 commits November 22, 2026 22:14
add:
- accept several URLs; validate all of them before sending any
- stop on a full queue (exit 9), a 429 (exit 6) or a 401 (exit 3) and list
  the inputs still to send in notSubmitted; other refusals go to failed
- --queue waits for a free slot (30 s polls, --queue-timeout per URL)
- one progress line per URL; Ctrl-C or SIGTERM prints the partial summary
  and exits 130
- send a git token with repositories only

upload:
- refuse files over 4.4 MB before sending (Context7 answers 413
  FUNCTION_PAYLOAD_TOO_LARGE above ~4.5 MB), with a split hint per file
  type; --skip-size-check overrides
- say the library id comes from the file name

Also: network failures come back as JSON instead of a traceback, every
command has --help text, log keeps stdout JSON, and the skill and plugin
are at version 1.2.

Docs: new Upload a file page, an "Add many sources" section, new gotchas
and exit codes; examples use this repo where a real source fits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- tests/test_c7.py: 46 unittest tests for c7.py with the Context7 API
  stubbed (no key, no network): input classification, website ids, add
  (single, several URLs, queue, refusals, validation, interrupts), upload
  (size limit, hints, 413, network errors), call() network failures, log
  and --help
- CI on push to main and on pull requests: tests on Python 3.8 to 3.13,
  syntax check, skill validation against the Agent Skills specification
  (skills-ref 0.1.1) and a coverage report
- README: CI, Python, license, last-commit, Agent Skills and Context7
  badges, and how to run the tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CI:
- run every job on ubuntu-24.04: setup-python has no Python 3.8 or 3.9
  builds for newer Ubuntu images, so ubuntu-latest would break those jobs
- test Python 3.8 to 3.14
- actions/checkout and actions/setup-python v7; coverage 7.17.4, with
  the coverage table also written to the job summary

Tests (58):
- stub c7's own time module instead of patching the global time.sleep
- help tests no longer depend on the terminal width; each command's own
  purpose and every flag's help text are checked
- fail when a stubbed response is left unused
- new: a real SIGTERM during a request (guarded, so a missing handler
  fails that test instead of killing the run), check, allow, refresh
  (queue full gives 9), api_key from the environment and from
  ~/.claude.json, multipart, network errors during add

c7.py: build_parser() for testable help; close an HTTP error response
when reading its body fails; say a network error during add is safe to
resubmit and counts as a failure; clearer exit 9 help.

context7.json: keep tests/ and .github/ out of the Context7 index.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@saalse
saalse merged commit 63238a3 into main Nov 22, 2026
8 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