Skip to content

fix: production hardening, test coverage, and GitHub App JWT#1

Merged
hermanngeorge15 merged 4 commits into
mainfrom
fix/production-hardening-and-tests
Mar 12, 2026
Merged

fix: production hardening, test coverage, and GitHub App JWT#1
hermanngeorge15 merged 4 commits into
mainfrom
fix/production-hardening-and-tests

Conversation

@hermanngeorge15
Copy link
Copy Markdown
Contributor

Summary

  • Fix all P0-P2 issues from code review (API route prefix, SSE Flusher, race conditions, HTTP timeouts, body limits, Prometheus cardinality, SQLite FK enforcement, auth query param removal, JSON error responses, daemon double-close, signal handling)
  • Handle silent errors in providers (time.Parse), tenant (LastInsertId), and daemon (store writes)
  • Implement real RS256 JWT for GitHub App using golang-jwt/jwt/v5 (replaces non-functional stub)
  • Add 83 tests across 8 new test files covering api, tenant, errors, githubapp, metrics, model, logging, ratelimit
  • Enable Homebrew formula in .goreleaser.yml
  • Add ADR-0001 documenting all architectural decisions

Changes

Category Files Details
P0 fixes api.go, metrics.go, server.go Route prefix, SSE Flusher, race condition
P1 fixes server.go, api.go, metrics.go, tenant.go, apikey.go, auth.go HTTP timeouts, body limits, Prometheus labels, FK pragma, auth hardening
P2 fixes daemon.go, serve.go, api.go sync.Once Stop, signal.NotifyContext, concurrent fetching
Error handling github.go, gitlab.go, tenant.go, daemon.go time.Parse, LastInsertId, store write logging
GitHub App app.go Real RS256 JWT with golang-jwt/jwt/v5
Tests 8 new *_test.go files 83 new tests, 21 test suites total
Docs docs/adr/0001-production-hardening.md ADR for all decisions
Release .goreleaser.yml Homebrew formula enabled

Test plan

  • go build ./... passes
  • go test ./... -count=1 — all 21 suites pass
  • go vet ./... — clean
  • gofmt — clean
  • Coverage: api 69.6%, tenant 81.9%, errors 100%, ratelimit 100%, logging 91.7%

🤖 Generated with Claude Code

hermanngeorge15 and others added 4 commits March 12, 2026 09:56
Fix all P0-P2 issues from code review:
- Fix API route prefix duplication (routes were 404ing)
- Add http.Flusher to metrics statusRecorder (SSE was broken)
- Add sync.RWMutex for config mutation race condition
- Add HTTP server timeouts (Read/Write/Idle)
- Add request body size limit on POST endpoints
- Normalize Prometheus path labels to prevent cardinality explosion
- Enable PRAGMA foreign_keys in SQLite tenant/apikey stores
- Remove query param API key auth (leak risk)
- Fix auth error responses to use application/json
- Guard daemon Stop() with sync.Once against double-close panic
- Replace os.Exit(0) with signal.NotifyContext for clean shutdown
- Make listServices fetch releases concurrently
- Log store write errors in daemon instead of swallowing
- Handle time.Parse and LastInsertId errors in providers/tenant
- Implement real RS256 JWT for GitHub App (golang-jwt/jwt/v5)
- Add 83 tests across 8 new test files (api, tenant, errors,
  githubapp, metrics, model, logging, ratelimit)
- Enable Homebrew formula in goreleaser
- Add ADR-0001 documenting all decisions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove WriteTimeout (was 60s) to avoid killing long-lived SSE
  connections; rely on ReadTimeout + IdleTimeout instead
- Fix golang-jwt/jwt/v5 go.mod marker from indirect to direct
- Use json.Marshal in writeJSONError to prevent invalid JSON from
  unescaped quotes in error messages
- Cap unknown path labels at 3 segments and collapse /dashboard/*
  to prevent Prometheus cardinality explosion on all routes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add CLAUDE.md with project conventions, build commands, and architecture
- Enable Codecov coverage upload in CI workflow
- Add CLI tests for version, init, check, help, and parseOwnerRepo
- Fix stdout capture for version command test (fmt.Printf → os.Pipe)
- Fix config loading in check test (use temp nonexistent config path)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Check os.Pipe() and buf.ReadFrom() return values in CLI tests
- Update ADR-0001 to reflect no WriteTimeout (SSE compatibility)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@hermanngeorge15 hermanngeorge15 merged commit 462d50e into main Mar 12, 2026
3 checks passed
@hermanngeorge15 hermanngeorge15 deleted the fix/production-hardening-and-tests branch March 12, 2026 10:32
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