GLM-5.3 Flash · 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 Opus 5.5.
- Gold bugs found
- 2 of 5
- Comments published
- 7
- Comments matching a bug
- 2
- Comments not matching
- 5
- Cost of this PR
- $0.210
Published comments (7)
Device-limit gate bypassed when X-Grafana-Device-Id header is omitted — Since `TagDevice` returns early when the client-controlled `X-Grafana-Device-Id` header is absent, simply omitting it bypasses the gate and the limit never applies to the unbounded traffic it is meant to cap. Enforce a server-side fallback identity (e.g. from IP/User-Agent) or reject requests missing the header.
Device cached before DB write, so limit rejection is bypassed on retry — Because `SetDefault` caches the device before `CreateOrUpdateDevice` runs, a rejected request succeeds on retry via a cache hit without touching the database — rejection silently becomes access. Cache the device only after `CreateOrUpdateDevice` succeeds, or evict the key on error. **Also found in:** - `pkg/services/anonymous/anonimpl/client.go:44-47`
Device limit check has a check-then-act race allowing limit bypass — `CountDevices` and the insert run in separate sessions without locking, so concurrent requests with distinct device IDs all see the count below the limit and all insert, letting one burst push far past the cap. Enforce it atomically, e.g. a locking read in one transaction or a conditional insert.
anonymousDeviceLimit typed as number | undefined but backend always sends a number (0 = no limit) — `undefined` never arrives: the Go DTO field `AnonymousDeviceLimit` always serializes a number, `0` when no limit is set, so consumers checking for `undefined` or treating any number as a real limit will misbehave. Type the field as `number` and document that `0` means unlimited.
Panic in TagDevice now escapes Authenticate after removing defer/recover — Panics raised inside `TagDevice`, for example while parsing request headers, now escape `Authenticate` and fail the request with a 500 instead of being swallowed as before. Wrap the synchronous call in a defer/recover that logs and treats the panic as a tagging failure.
Authenticate leaks internal ErrDeviceLimitReached sentinel in HTTP response — Returning the raw `ErrDeviceLimitReached` sentinel makes it the response message for unauthenticated requests, disclosing to anonymous users that a device limit exists and is exhausted. Log the real cause server-side and return a neutral authentication failure instead.
AnonymousDeviceLimit leaks internal capacity config via unauthenticated /api/frontend/settings — The endpoint is served without authentication, so this publishes the internal capacity setting to any visitor, and no frontend consumer of the value appears in this PR. Omit it from the payload or include it only when anonymous access is enabled.