Skip to content

feat: effect document, github-repo targets and GitHub REST client - #2

Open
ccf-lisa[bot] wants to merge 3 commits into
effector/01-scaffold-paramsfrom
effector/02-github-client
Open

ccf-lisa[bot] wants to merge 3 commits into
effector/01-scaffold-paramsfrom
effector/02-github-client

Conversation

@ccf-lisa

@ccf-lisa ccf-lisa Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Stack 2/5 for effector-github-settings: the effect document, github-repo targets and the GitHub REST client.

Part 2 (GitHub client) of Plugins → effector-github-settings; LLD (Manifest target scheme, Rule parameters' GitHub calls, Testing). Ported from the PoC.

What

  • internal/document.go: the fields of the effect document the plugin reads (accepts the effect or a whole webhook body), and ParseTarget for github-repo:github.com/<owner>/<repo> (rejects other schemes, bad values, ./..).
  • internal/github.go: a small net/http client for the five calls the plugin makes: GET /repos/{o}/{r}, PATCH it (web commit signoff), GET/DELETE direct collaborators (affiliation=direct), GET/DELETE invitations. GitHub's Accept and API version headers, a 30s timeout, Link pagination (100 per page, at most 100 pages) that refuses next URLs off the API host so the token never leaves it. Errors read <METHOD> <path>: <status> <GitHub message> (with the rate-limit reset time when GitHub sends one), capped at 300 characters, never the token or URL.
  • The client never follows redirects (a renamed or transferred repository answers 301/307 to its new location, outside the action's targets): it fails with repository moved to …, and getRepository/setWebCommitSignoff fail when full_name isn't the target's (case aside).
  • Tests against an httptest fake GitHub (fakegithub_test.go, reused by later PRs): reads and writes, pagination, page cap, off-host links, 401/403/404, rate limit, non-JSON bodies, long messages, GHE base path, transport errors. No test calls the real GitHub API.

Deviation from the PoC

  • apiError omits the status when there was no response (it printed GET /x: 0 canceled).

Local gate

Build, vet, go test -race, golangci-lint v2.15.0 with the shared workflows config (0 issues), go mod tidy clean, with the sibling checkouts. CI fails on module resolution until 5/5 (accepted).

The shared lint config (CI since 1/5) enables bodyclose and errorlint: send returns the response headers instead of the response (it already closed the body), and the Link URL parse error is wrapped with %w.

Counted lines: 1026 (size-exception: the redirect fix and its 301/307 tests from review).

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: d059291f-18fa-4820-816f-330787196ac0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@ccf-lisa
ccf-lisa Bot added this pull request to stack #6 December 2, 2026 10:31
@ccf-lisa
ccf-lisa Bot force-pushed the effector/02-github-client branch from fbfccd1 to 1387be9 Compare December 2, 2026 11:00

@gusfcarvalho gusfcarvalho left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ccf-review: REQUEST_CHANGES

1 Blocker.

Stack (gh stack 6): #1 → #2 → #3 → #4 → #5

Comment thread internal/github.go Resolved
ccf-lisa Bot and others added 3 commits December 2, 2026 20:49
The effect document fields the plugin reads, the github-repo target scheme, and a small GitHub
REST client over net/http for the calls the plugin makes (repository, direct collaborators,
invitations, web commit signoff), with Link pagination kept on the API host and errors that
carry the call and GitHub's message but never the token. Tests use an httptest fake GitHub.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The shared golangci-lint config the CI now uses enables bodyclose and errorlint: send
returns the response headers instead of the response (it already closes the body), and
the Link URL parse error is wrapped with %w.
GitHub redirects a renamed or transferred repository's calls (301 GET,
307 PATCH/DELETE) to its new location, and net/http followed them with
the token, so an action could change a repository its targets don't
allow. The client no longer follows redirects and fails with
"repository moved to …"; getRepository and setWebCommitSignoff also
fail when full_name differs (ignoring case) from the target.
@ccf-lisa
ccf-lisa Bot force-pushed the effector/02-github-client branch from 1387be9 to 396270e Compare December 2, 2026 23:50
@ccf-lisa

ccf-lisa Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Adding size-exception: this PR is now 1026 counted lines (go.sum excluded), up from 945. The review blocker (redirects and the full_name check) belongs in the GitHub client this PR introduces, and its fake-GitHub tests for a 301 and a 307 add about 55 test lines. Moving the client or its tests to another PR would split the code from its review.

@gusfcarvalho gusfcarvalho left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ccf-review: APPROVE

no findings.

Stack (gh stack 6): #1 → #2 → #3 → #4 → #5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant