MiniMax M3 · Heavy

anonymous-add-configurable-device-limit-grafana-codex

Grafana · Go · M · 100–299 lines · 6 files

The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Haiku 5.5.

Gold bugs found
0 of 2
Comments published
3
Comments matching a bug
0
Comments not matching
3
Cost of this PR
$0.314

Published comments (3)

highbugpkg/services/anonymous/anonimpl/anonstore/database.go:73-103

updateDevice misreports stale device as ErrDeviceLimitReached — A device record aged 30-61 days won't match `updatedDevice`'s WHERE clause but still exists in the table, so callers can't tell stale from 'limit reached' and returning users get a wrong rejection. Check existence for the device first, then apply the `updated_at` window to distinguish the two outcomes.

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

CreateOrUpdateDevice count+insert race can exceed device limit — `CreateOrUpdateDevice` reads `CountDevices` then conditionally inserts with no transaction or row lock, so concurrent new-device callers both see room and exceed `deviceLimit`. Wrap the count+insert in a serializable transaction, or use a SQL row-level constraint as the limiter.

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

Anonymous Authenticate now blocks on TagDevice on the auth hot path — Anonymous auth now blocks synchronously on `TagDevice` -> `CreateOrUpdateDevice`, adding a guaranteed `CountDevices` round-trip and an extra COUNT scan per request when `deviceLimit > 0`. Keep the tag async for non-limit branches; only the `ErrDeviceLimitReached` case needs a synchronous read.

Gold bugs found (0)

None.

Gold bugs missed (2)

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