Claude Sonnet 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
3
Comments matching a bug
1
Comments not matching
2
Cost of this PR
$0.467

Published comments (3)

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

Rejected device stays in cache, bypassing the anonymous device limit — The rejected device's next request within the 29-minute cache TTL passes the cache check, so `Authenticate` grants it anonymous access and the limit is bypassed. Call `localCache.Delete(key)` in `tagDeviceUI` when `CreateOrUpdateDevice` fails, or set the entry only after a successful write.

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

Device limit check is racy: COUNT then unconditional upsert can exceed limit — Concurrent requests from new devices can all read a count below `deviceLimit` and all insert, so the limit is exceeded. Make the `CountDevices` check and the insert atomic, for example with a conditional `INSERT ... SELECT` or a serialized transaction.

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

`TagDevice` now runs synchronously in `Authenticate`, slowing anonymous requests — Every uncached device now adds a COUNT query and an upsert to the request path, even when `device_limit` is 0, so slow DB writes delay requests and request cancellation aborts tagging. Keep tagging asynchronous when no limit is set, and run it synchronously only when `AnonymousDeviceLimit > 0`.

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.