DeepSeek V4 Pro · 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 Opus 5.5.

Gold bugs found
2 of 5
Comments published
4
Comments matching a bug
2
Comments not matching
2
Cost of this PR
$0.561

Published comments (4)

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

TagDevice caches device key before store, bypassing device limit on retry — The retry then authenticates because the cached key returns nil before the store sees it. Only cache after a successful store write, or skip caching when the error is anonstore.ErrDeviceLimitReached.

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

Concurrent CreateOrUpdateDevice can exceed device limit due to check-then-act race — Concurrent requests can all pass CountDevices before any insert, then exceed the cap. Wrap the count and write in a single transaction, or enforce the limit with a constraint/lock.

highbugpkg/services/anonymous/anonimpl/anonstore/database.go:74-78

updateDevice uses '?' placeholders on PostgreSQL, breaking limit enforcement — On PostgreSQL the UPDATE fails, so updateDevice never returns ErrDeviceLimitReached and the cap is silently unenforced. Use the same dialect switch as CreateOrUpdateDevice to select $N placeholders for migrator.Postgres.

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

Stale wire binding and provider for AnonDBStore remain after constructor change — The int64 parameter from ProvideAnonDBStore now has no provider in the graph, and the binding is orphaned since nothing injects anonstore.AnonStore. Remove or update the stale entries in pkg/server/wire.go to match the new construction path.

Gold bugs found (2)

highThe device limit check counts devices and then inserts in separate non-atomic steps, so concurrent requests from new devices can all pass the check and exceed the configured limit.
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 (3)

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.
mediumupdateDevice prepends the query to the captured args inside the retried DB callback, so a SQLite lock retry runs Exec with the query duplicated in the arguments and the update fails.
highClaims a client disconnect cancels the context, TagDevice fails with context.Canceled, and Authenticate still succeeds without counting the device, bypassing the limit.