Skip to content

Add upload_coverage_files to the Python SDK clients - #71

Open
aymandakir wants to merge 7 commits into
prooflinedev:mainfrom
aymandakir-lab:feat/upload-coverage-files
Open

aymandakir wants to merge 7 commits into
prooflinedev:mainfrom
aymandakir-lab:feat/upload-coverage-files

Conversation

@aymandakir

Copy link
Copy Markdown

Problem

The Python SDK only exposes upload_coverage_reports, which needs the caller to build the request body by hand. The TypeScript SDK already has a file-based helper, so Python users have no easy way to upload coverage files from disk.

Approach

  • New proofline/coverage.py with CoverageFile and build_coverage_request. It reads files, names them by path relative to a root (symlinks resolved, escapes refused), and validates the input.
  • New upload_coverage_files(organization_id, repository_id, *, tested_sha, files, root=None) on the sync and async clients. The async client reads files in a worker thread so the event loop is not blocked.
  • CoverageFile is exported from the package, and the README has a short example.

Validation

  • tested SHA must be the full 40 hex characters
  • 1 to 50 reports, unique names, UTF-8 only
  • explicit names must be relative with no .., and every file must resolve inside root
  • total body capped at 30 MiB (measured on the serialized JSON)
  • invalid input raises ValueError and sends no request; missing files raise OSError

Verification

  • 23 new tests in tests/test_coverage_files.py, including sync and async HTTP tests that check the exact request body
  • full suite: 241 passed
  • ruff clean on the changed files; no new mypy errors (existing ones in tests/test_http.py unchanged)

Reproduce: python3 scripts/check.py or pytest tests/test_coverage_files.py

Proofline review of this PR

I installed Proofline on my own org (aymandakir-lab) and ran it on this branch in my fork (aymandakir-lab#1). It posted 3 findings, two of which are the same bug and one a test gap. I agreed with all of them.

  1. Explicit report names bypassed root containment. A CoverageFile with a custom name skipped the only check that the resolved file stays inside root, so an outside file or an escaping symlink could be uploaded. Fixed: the resolved path is checked against root for every report; the explicit name only decides the name sent. Tests added for an absolute outside path and an escaping symlink, both with an explicit name.
  2. The size test did not distinguish raw from serialized size. Added one case whose raw content fits but whose JSON body exceeds 30 MiB, and one boundary case just under the limit that is accepted.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TULLGRKGHLApVfsBmhCpPy

aymandakir and others added 7 commits November 20, 2026 09:39
Addresses the Proofline review: a custom CoverageFile.name no longer skips the root check.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TULLGRKGHLApVfsBmhCpPy
Covers the Proofline review findings: explicit names must still stay inside root, and the size cap counts the JSON body.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TULLGRKGHLApVfsBmhCpPy

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.

1 participant