Claude Opus 5.5 · Balanced
anonymous-add-configurable-device-limit-grafana-codex
Grafana · Go · M · 100–299 lines · 6 files
The normal review, with one generalist agent. Judge: Claude Haiku 5.5.
- Gold bugs found
- 1 of 2
- Comments published
- 4
- Comments matching a bug
- 1
- Comments not matching
- 3
- Cost of this PR
- $0.740
Published comments (4)
ProvideAnonDBStore takes a bare int64 that no wire provider supplies — Wire generation fails because `pkg/server/wire.go` still registers `anonstore.ProvideAnonDBStore`, while the store is now built by hand in `ProvideAnonymousDeviceService`. Drop `anonstore.ProvideAnonDBStore` and its `wire.Bind` from wire.go, or take `*setting.Cfg` instead of a bare `int64`.
Device rejected for hitting the limit is still cached and later let in — `tagDeviceUI` caches the device key in `localCache` before `CreateOrUpdateDevice` runs, so a device rejected with `ErrDeviceLimitReached` logs in anonymously on its next requests within 29 minutes. Set the cache entry only after `CreateOrUpdateDevice` succeeds.
Device limit check and insert are not atomic, so concurrent requests can exceed the limit — Concurrent requests from different new devices can all pass `count < deviceLimit` before any insert lands, pushing past the configured limit. Run `CountDevices` and the insert atomically, for example with a conditional insert or a serializable transaction.
Device tagging now blocks the anonymous auth path on DB queries — Each uncached anonymous request in `Authenticate` now waits on a `COUNT(*)` over `anon_device` plus an upsert, adding DB latency that grows with the table. Block on the limit check only when `AnonymousDeviceLimit > 0`, and keep the async path with its own timeout otherwise.