Skip to content

fix: strip owner prefix from --repo before sending to GitHub access_tokens API#4

Merged
akuehner merged 1 commit into
mainfrom
fix/repo-name-bare-for-github-api
Jun 16, 2026
Merged

fix: strip owner prefix from --repo before sending to GitHub access_tokens API#4
akuehner merged 1 commit into
mainfrom
fix/repo-name-bare-for-github-api

Conversation

@akuehner

Copy link
Copy Markdown
Member

See PR description

…okens API

GitHub's POST /app/installations/{id}/access_tokens `repositories` field
expects bare repo names ("clagentic-directory"), not "owner/name" form.
The installation is org-scoped via installation_id, so the owner is implicit.

Add parseRepoName() helper that accepts "owner/name" or bare "name" input
and returns the bare name. Empty, multi-slash, or malformed inputs return a
descriptive error before any API call is made.

The --repo CLI flag contract is unchanged: callers continue to pass
"owner/name" (e.g. clagentic/clagentic-directory). Only the value sent to
GitHub becomes the bare name segment.

Before: repositories: ["clagentic/clagentic-directory"] -> GitHub 422
After:  repositories: ["clagentic-directory"] -> token minted correctly

Also update Makefile to explicitly set GOPATH/GOMODCACHE/GOCACHE (matching
the relay project pattern) so `make test` resolves the Go module cache
without requiring GOPATH in the invoking environment.

Tests: table-driven unit tests for parseRepoName (all documented edge cases)
plus two integration-level tests capturing what is sent to a stub GitHub API.
All tests pass (`make test`).
@akuehner akuehner merged commit 9676bfd into main Jun 16, 2026
1 check passed
@akuehner akuehner deleted the fix/repo-name-bare-for-github-api branch June 16, 2026 19:38
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