fix(controlplane): enforce cache-invalidating project repo and wire bootstrap licenser#2704
Merged
mekilis merged 1 commit intoJul 7, 2026
Conversation
…ootstrap licenser wire the api layer's ProjectRepo through a single cached repository so every write path invalidates the projects:<id> cache key. previously several handlers constructed their own uncached repo, so config updates via the api were served stale for up to the cache ttl. also pass the licenser into CreateOrganisationService from the bootstrap command; it was omitted and caused a nil-pointer panic on convoy bootstrap, and guard the service against a nil licenser with a clear error.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ProjectRepothrough a single cached repository (ensureAPIRepositories) so every write path invalidates theprojects:<id>cache key. Previously several handlers built their own uncached repo viaprojects.New(...), so project config updates made through the API were served stale for up to the cache TTL. All handler call sites (project.go,organisation.go,endpoint.go,security.go,subscription.go,ingest.go) now consume the shared repo viah.projectRepo(), andcmd/utils/circuit_breakers.gowraps its repo in the same cache when available. Introducedcached.DefaultProjectTTLso the API and dataplane worker share one TTL constant.convoy bootstrap: the command constructedCreateOrganisationServicewithout theLicenser, so organisation creation crashed. The licenser is now passed through, and the service guards against a nil licenser with a clear error instead of panicking.Test plan
go build ./...api,api/handlers,services,datastore/cachedpass, including new tests: cached-vs-plain repo wiring inensureAPIRepositories, shared repo usage increateProjectService, and nil-licenser error inCreateOrganisationServicego vetandgolangci-lintclean on touched packagesNote
Medium Risk
Touches many API write/read paths and project config caching; incorrect wiring could still serve stale config, but changes are narrowly scoped to repo injection and invalidation.
Overview
Fixes stale project config when the API or dataplane read
projects:<id>from cache: startup now wrapsProjectRepoinCachedProjectRepositorywhen a cache exists, and handlers/ingest/CLI paths stop building uncachedprojects.New(...)repos and use the shared wired instance (h.projectRepo()ora.A.ProjectRepo) so updates invalidate the cache key. Addscached.DefaultProjectTTL(5m) for API wiring, dataplane worker, and the circuit-breakers CLI.Also fixes
convoy bootstrap: passesLicenserintoCreateOrganisationServiceand returns a clear error ifLicenseris nil instead of panicking on org limit checks.Regression tests cover cached vs plain repo wiring,
createProjectServicerepo reuse, and nil licenser behavior.Reviewed by Cursor Bugbot for commit 5a10d25. Bugbot is set up for automated code reviews on this repo. Configure here.