Skip to content

Add find_repository to resolve owner/name to a repository - #63

Open
Adii-5442 wants to merge 4 commits into
prooflinedev:mainfrom
Adii-5442:feat/find-repository
Open

Adii-5442 wants to merge 4 commits into
prooflinedev:mainfrom
Adii-5442:feat/find-repository

Conversation

@Adii-5442

Copy link
Copy Markdown

Who this helps

Anyone calling request_review, request_patch_review, upload_coverage_reports or the other repository operations from CI or a script. Those calls take the repository's stable Proofline ID, but a GitHub Actions job only knows GITHUB_REPOSITORY (owner/name). Today every caller lists repositories and writes their own matching loop, and the easy versions of that loop get case handling wrong or silently take the first partial match.

repository = client.find_repository(organization_id, os.environ["GITHUB_REPOSITORY"])
client.request_review(organization_id, repository.id, pull_request_number)

What it does

  • find_repository(organization_id, full_name) on both ProoflineClient and AsyncProoflineClient, built on one list_repositories read. It returns the typed RepositoryName, which is now exported from proofline.
  • Matches ignore ASCII case, the way GitHub compares owner/name, and an exact spelling wins over a variant that differs only in case. Only ASCII letters fold, so a Unicode look-alike such as the Kelvin sign in \u212ait never resolves to kit.
  • A malformed name (not exactly one /, an empty part, surrounding whitespace, or a non-string) raises ValueError before any request, following the head_commit_sha pattern.
  • No match raises ProoflineError with urn:proofline:sdk:repository-not-found. The detail notes that a repository-restricted token only sees its allowlist and that a renamed repository is listed under its new name, the two usual reasons a name is missing.
  • More than one match raises urn:proofline:sdk:ambiguous-repository instead of guessing.
  • Both SDK problems use status 0 like the other client-side problems and carry the name in repository_name. Server problems from the list call, such as a 403, are kept unchanged.
  • Registered in scripts/contracts.py next to iter_reviews and wait_for_review, so the operation-coverage contract still holds.
  • README section with the GitHub Actions example and the matching rules.

Decisions

  • Exact match first, then case-insensitive. GitHub treats Octo-Org/API and octo-org/api as the same repository, so callers should not have to normalize. If a listing ever holds two entries that differ only in case, the caller's exact spelling is the strongest signal; anything still ambiguous is refused, not guessed.
  • No partial or fuzzy matching. octo-org/ap or octo/api must never resolve to octo-org/api in CI, because that would request a review on the wrong repository.
  • No caching. Names change on a rename and token allowlists change, so the docstring and README tell callers to keep repository.id.

How I verified it

  • New tests in tests/test_http.py against the real loopback server, for both the sync and async clients (10 cases):
    • resolves the exact and the case-insensitive name to the right ID, never to a sibling like octo-org/api-docs or other-org/api
    • exact spelling wins; case-only ambiguity and duplicate entries are refused
    • unseen names, prefixes, the wrong owner, an empty listing and the Kelvin sign look-alike all report repository-not-found, and the detail never contains the token
    • a 403 from the list endpoint keeps the server problem
    • 13 malformed inputs raise ValueError with zero requests sent
  • Confirmed the Unicode test fails if the match uses plain str.lower().
  • python3 scripts/check.py passes end to end: regeneration, contracts, ruff, mypy, 226 tests, and the wheel and sdist smoke installs.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WS5MykmV7shybNY7mjLYLt

Adii-5442 and others added 4 commits November 18, 2026 10:04
Review requests and coverage uploads take the repository's stable Proofline ID, but CI and scripts usually know the provider's owner/name (GITHUB_REPOSITORY in GitHub Actions). find_repository resolves it on the sync and async clients with one list_repositories read, and RepositoryName is now exported from proofline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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