MiniMax M3 · 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
2
Comments matching a bug
1
Comments not matching
1
Cost of this PR
$0.133

Published comments (2)

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

Race between device-count check and insert can exceed deviceLimit — Concurrent inserts in `CreateOrUpdateDevice` bypass `deviceLimit` because `CountDevices` and the `INSERT … ON CONFLICT` run as separate statements. Wrap both in a single `WithTransactionalDbSession` at SERIALIZABLE, or push the cap into a conditional `INSERT` that aborts when the count threshold is met.

highbugpkg/services/anonymous/anonimpl/impl.go:147

Cache device key before DB write allows bypass of device limit — `tagDeviceUI` writes to `a.localCache` before `CreateOrUpdateDevice` runs, so a request rejected with `ErrDeviceLimitReached` still authenticates from cache during the TTL. Move `localCache.SetDefault` after a successful DB write (or invalidate the key on error).

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.