Skip to content

Refactor: upgrade deps, improve reliability, update docs and tooling#4

Open
cbullinger wants to merge 25 commits intomainfrom
refactor/cursor-recs
Open

Refactor: upgrade deps, improve reliability, update docs and tooling#4
cbullinger wants to merge 25 commits intomainfrom
refactor/cursor-recs

Conversation

@cbullinger
Copy link
Collaborator

@cbullinger cbullinger commented Feb 14, 2026

Summary

Major refactor covering dependency upgrades, reliability improvements, documentation overhaul, and tooling updates.

Dependency Upgrades

  • Go 1.24.0 → 1.26.0
  • google/go-github v48 → v82
  • mongo-driver v1 → v2

Reliability & Features

  • Rate limit handling: RateLimitTransport with auto-retry on 403/429
  • Webhook idempotency: DeliveryTracker deduplicates via X-GitHub-Delivery header
  • Structured logging: migrated to log/slog with JSON output for Cloud Logging
  • Sentinel errors: ErrRateLimited, ErrNotFound, etc. in errors.go
  • Token manager: thread-safe token state with sync.RWMutex
  • Readiness endpoint: /ready probe separate from /health liveness
  • Dry-run enforcement: DryRun flag now actually prevents writes (was cosmetic-only)

Docs & Config

  • Deleted stale/duplicative docs (QUICK-REFERENCE.md, DEBUG-LOGGING.md, RECOMMENDATIONS.md)
  • Updated all docs for Cloud Run (removed App Engine references), /events webhook path, slog logging
  • Deleted legacy app.yaml (App Engine Flex config)
  • Added github-app-manifest.yml documenting required permissions and events
  • Updated LOCAL-TESTING.md with GitHub App auth setup (SKIP_SECRET_MANAGER flow)
  • Fixed default WebserverPath from /webhook to /events

Scripts

  • Deleted obsolete scripts (convert-env-format.sh, convert-env-to-yaml.sh, validate-config-detailed.py)
  • Added ci-local.sh (mirrors CI pipeline locally)
  • Updated all scripts for Cloud Run, correct binary name, /events path

CLI Tools (cmd/)

  • test-webhook: added X-GitHub-Delivery header, fixed stale URLs
  • config-validator: init now supports basic/glob/regex templates, fixed type: "pr""pull_request"
  • test-pem: rewritten with proper error handling, added README

CI

  • Updated ci.yml for Go 1.26, added security scanning (gosec, Trivy)
  • Kept SERVICE_NAME: "examples-copier" to deploy to existing Cloud Run service
  • Dockerfile binary renamed internally to github-copier

Test plan

  • go build ./... passes
  • go test -race ./... passes
  • golangci-lint run ./... passes
  • Local dry-run test with smee webhook forwarding (confirmed dry-run prevents writes)
  • Local test against production config (grove-platform/github-copier.copier/main.yaml)
  • CI pipeline passes on this PR
  • Deploy to Cloud Run and verify /health, /ready, /metrics endpoints
  • Verify webhook processing on production with a real merged PR

Made with Cursor

cbullinger and others added 25 commits January 13, 2026 16:13
The workflow processor was creating UploadKey with BranchPath set to just
the branch name (e.g., 'main') instead of the full ref path (e.g.,
'refs/heads/main'). This caused GitHub API calls to fail with 404 errors
when trying to access the branch ref.

This fix ensures BranchPath is always set with the 'refs/heads/' prefix,
consistent with how it's used throughout the rest of the codebase.
- Add GetRestClientForOrg() to get installation-specific tokens
- Fix GraphQL query to use node(id:) instead of repository(owner:)
- Update RetrieveFileContentsWithConfigAndBranch to use org-specific client
- Remove refs/heads/ prefix duplication in workflow processor
- Fixes 404 errors when accessing repos in different orgs
- Add explicit 'GITHUB APP AUTHENTICATION FAILED' message for 401 errors
- Point users to check CODE_COPIER_PEM secret in GCP Secret Manager
- Add detection in getInstallationIDForOrg, getInstallationAccessToken
- Add detection in config_loader and main_config_loader when fetching configs

This makes it immediately obvious when the PEM key is invalid/expired
instead of showing misleading 'failed to load config' errors.
golangci-lint v1.x is built with Go 1.24 and can't analyze Go 1.26 code.
Pin to v2.9.0 which supports Go 1.26. Similarly, the gosec Docker action
bundles Go 1.25.7 — switch to `go install` so it uses the Go 1.26 from
setup-go.

Co-authored-by: Cursor <cursoragent@cursor.com>
golangci-lint-action v6 doesn't support golangci-lint v2. Switch to
action v7 which does.

gosec @latest includes new taint analysis rules (G703-G706) that flag
all http.Client.Do() calls as SSRF and CLI os.ReadFile as path traversal.
These are false positives for this codebase — exclude globally alongside
the existing G115 exclusion.

Co-authored-by: Cursor <cursoragent@cursor.com>
- Wrap deferred Close() calls to satisfy errcheck
- Replace deprecated github.String/Int/Bool with github.Ptr (SA1019)
- Apply De Morgan's law to simplify boolean expressions (QF1001)
- Remove unused parseIntWithDefault function
- Use t.Setenv in tests instead of unchecked os.Setenv (errcheck)
- Use system golangci-lint v2.9.0 in pre-commit for full coverage

Co-authored-by: Cursor <cursoragent@cursor.com>
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