Skip to content

Document the repository form for pull request review lookups - #160

Open
mkab wants to merge 1 commit into
prooflinedev:mainfrom
mkab:docs/pull-request-repository-name
Open

mkab wants to merge 1 commit into
prooflinedev:mainfrom
mkab:docs/pull-request-repository-name

Conversation

@mkab

@mkab mkab commented Dec 3, 2026

Copy link
Copy Markdown

Who this helps

Anyone calling list_pull_request_reviews or get_pull_request_review from CI or a script. Both take repository: str, and nothing in the SDK said which form. The server wants the repository name without its owner and refuses owner/name with 400. In GitHub Actions the value at hand is GITHUB_REPOSITORY, which is owner/name, and client.fixes.list_open_findings on the same client requires owner/name. Since str(ProoflineError) shows only the status, the failure reads as "Proofline request failed (HTTP 400)." unless you go and read error.detail.

What changed

Docs and one test. No change to proofline/ or to runtime behaviour.

 README.md
   ## Resolve a repository
+  ## Look up a pull request's reviews
+    repository name for the two REST lookups, owner/name for fixes.list_open_findings,
+    400 on owner/name with the reason in error.detail, GITHUB_REPOSITORY example
   ## Errors and refusals
 tests/test_http.py
+  test_pull_request_lookups_send_the_repository_name_unencoded   (sync and async)

The README example:

owner, name = os.environ["GITHUB_REPOSITORY"].split("/", 1)
organization_id = UUID(os.environ["PROOFLINE_ORGANIZATION_ID"])

with ProoflineClient() as client:
    page = client.list_pull_request_reviews(organization_id, name, 12)
    findings = client.fixes.list_open_findings(f"{owner}/{name}", 12)

Decisions

  • Docs, not code. The client sends what it is given, and that matches the contract: openapi.public.json describes repository as "The repository's name without its owner, or a name it had before a rename."
  • No docstrings in client.py, which has almost none; the README is where readers look.
  • The existing "repo/name" fixtures stay. They test that / is percent-encoded in the path segment, which is still worth testing. The new test covers the form the server accepts.
  • The README wording covers GitHub only. I have no live evidence for GitLab subgroup paths, so it makes no claim about them.
  • str(ProoflineError) showing only the status is documented design, so I point to error.detail instead of changing the message.

Live example

Against the live API, sync and async gave identical results. Organization, repository and review IDs are removed.

  1. list_pull_request_reviews(org, "<owner>/<name>", <n>):

    status: 400
    type:   about:blank
    title:  invalid request
    detail: repository must be the repository's name without its owner, such as web for acme/web
    str(error):  Proofline request failed (HTTP 400).
    repr(error): ProoflineError(status=400)
    
  2. list_pull_request_reviews(org, "<name>", <n>): 200, a ReviewPage with the pull request's reviews.

  3. fixes.list_open_findings("<name>", <n>):

    {"isError": true, "structuredContent": {"error": {"code": "INVALID_INPUT", "message": "repository is owner/name and pull_request_number is a positive integer; other arguments are refused.", "retryable": false}, "ok": false}}

    fixes.list_open_findings("<owner>/<name>", <n>): isError: false, ok: true.

get_pull_request_review(org, "<owner>/<name>", <n>, 1) gives the same 400 and detail; with "<name>" it returns the review.

So the two REST lookups take the name, and the MCP fix tool takes owner/name.

How it's tested

  • New offline test, in both modes: calls both REST lookups with "web" (the server's own example) against the local test server and asserts the paths are .../reviews/pr/web/42 and .../reviews/pr/web/42/runs/3, with no percent-encoding. Passing "acme/web" instead makes it fail.
  • python3 scripts/check.py passes: generation check, contracts, ruff, mypy, 236 tests, both built artifacts installed and smoke-tested.

Try it in a minute

Offline:

python3 scripts/check.py --prepare
.venv/bin/python -m pytest tests/test_http.py -k repository_name_unencoded -v

Live, with a reviews:read token in PROOFLINE_TOKEN and a pull request that has a review:

GITHUB_REPOSITORY=owner/name PROOFLINE_ORGANIZATION_ID=<uuid> PR=<number> python - <<'EOF'
import os
from uuid import UUID
from proofline import ProoflineClient, ProoflineError

owner, name = os.environ["GITHUB_REPOSITORY"].split("/", 1)
org, pr = UUID(os.environ["PROOFLINE_ORGANIZATION_ID"]), int(os.environ["PR"])
with ProoflineClient() as client:
    try:
        client.list_pull_request_reviews(org, f"{owner}/{name}", pr)
    except ProoflineError as error:
        print(error, error.detail)
    print(len(client.list_pull_request_reviews(org, name, pr).items), "reviews")
EOF

How I found this and what I left out

I ran every client operation against the live API, sync and async, and compared the responses with openapi.public.json. Of 11 differences, this is the one on the SDK side that no open PR covers.

A client-side refusal of / would fit next to the path checks in #84; I left it out so the two don't conflict.

list_pull_request_reviews and get_pull_request_review take the repository
name without its owner, while fixes.list_open_findings takes owner/name.
Add a README section with a GITHUB_REPOSITORY example and a test that a
bare repository name reaches the server unencoded.

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