GLM-5.3 · 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
- 1 of 2
- Comments published
- 6
- Comments matching a bug
- 1
- Comments not matching
- 5
- Cost of this PR
- $1.912
Published comments (6)
Unauthenticated device tagging can exhaust the global cap and break anonymous auth — An attacker can fill the global cap with arbitrary `X-Grafana-Device-Id` values via `TagDevice`, locking out every genuine new anonymous device for ~30 days. Throttle or bound anonymous device creation per client IP.
Wire provider set still registers ProvideAnonDBStore under old single-arg contract — `pkg/server/wire.go` still lists `anonstore.ProvideAnonDBStore` with no provider for a bare `int64`, so wire generation breaks. Remove the stale entry and regenerate the wiring.
Device-limit error path leaves stale cache entry, letting over-limit devices through on retry — `tagDeviceUI` caches the device key before calling `CreateOrUpdateDevice` and never evicts it on failure, so an over-limit device is denied once and then granted for 29 minutes. Delete the `localCache` entry when `CreateOrUpdateDevice` returns `ErrDeviceLimitReached`.
Device-limit check is a check-then-act race; concurrent requests can exceed the cap — `CountDevices` and the subsequent insert run in separate DB sessions with no transaction or lock, so concurrent first-requests can all pass the check and exceed the cap. Wrap the count and write in a single transaction or enforce the limit atomically.
ErrDeviceLimitReached returned raw, surfacing as generic internal auth error — The auth middleware only renders `authn.Error` values, so a raw `anonstore.ErrDeviceLimitReached` surfaces as an indistinguishable internal fault on every request. Return the sentinel as an `authn.Error` with a status code and reason.
Dropped recover lets TagDevice panics fail anonymous requests — The old goroutine's `recover()` guaranteed a tagging panic only logged a warning; without it, panics now surface as a generic 500 on anonymous requests. Keep a recover around the synchronous `TagDevice` call.