DeepSeek V4.1 Flash · 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.121

Published comments (4)

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

Rejected device stays cached, bypassing the device limit — A device that was just rejected gets cached by `localCache.SetDefault` before the store call, so its next request returns early and the limit is bypassed. Move that cache write after the store call succeeds.

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

Non-atomic device limit check allows exceeding the limit — Concurrent requests all see `count < deviceLimit` before any write lands, so bursts can exceed the limit by any amount. Make the check and insert atomic with a transaction, lock, or unique constraint.

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

Anonymous auth blocks on TagDevice DB round-trips — Every uncached anonymous request now pays a `SELECT COUNT(*)` plus a write against `anon_device` on the auth path, and blocked devices still do a COUNT and failing UPDATE each time. Move `TagDevice` back off the request path.

mediumbugpkg/services/anonymous/anonimpl/anonstore/database.go:84

Retry closure reassigns captured args, duplicating query on retry — `WithDbSession` retries the callback on lock errors, and reassigning the captured variable prepends the query again, sending it twice. Build the args slice locally inside the callback.

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.