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)

highbugpkg/services/anonymous/anonimpl/anonstore/database.go:52-53

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`.

highbugpkg/services/anonymous/anonimpl/impl.go:144-148

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.

highbugpkg/services/anonymous/anonimpl/anonstore/database.go:108-118

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.

mediumperformancepkg/services/anonymous/anonimpl/client.go:44-50

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.

Gold bugs found (1)

hightagDeviceUI caches the device key before CreateOrUpdateDevice; when the store returns ErrDeviceLimitReached the entry stays, so the next request from the same device skips the limit check and authenticates for up to 29 minutes.

Gold bugs missed (1)

highThe new auth.anonymous device_limit setting has no entry in conf/defaults.ini, so the GF_AUTH_ANONYMOUS_DEVICE_LIMIT environment override is ignored and the limit stays 0.