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