Anonymous: Add configurable device limit#12
Conversation
* Anonymous: Add device limiter * break auth if limit reached * fix typo * refactored const to make it clearer with expiration * anon device limit for config --------- Co-authored-by: Eric Leijonmarck <eric.leijonmarck@gmail.com>
Codoki PR ReviewSummary: Add anonymous device limit, expose in runtime config Issues (Critical & High only)
Showing top 1 issues. Critical: 0, High: 1. See inline suggestions for more. Key Feedback (click to expand)
Confidence: 3/5 — Needs work before merge (1 high · status: Requires changes) React with 👍 or 👎 if you found this review useful. |
| newCtx, cancel := context.WithTimeout(context.Background(), timeoutTag) | ||
| defer cancel() | ||
| if err := a.anonDeviceService.TagDevice(newCtx, httpReqCopy, anonymous.AnonDeviceUI); err != nil { | ||
| a.log.Warn("Failed to tag anonymous session", "error", err) |
There was a problem hiding this comment.
🔷 Medium: TagDevice now runs synchronously in the auth path; a slow DB will delay authentication. Wrap the call in a short timeout to keep auth responsive while still enforcing the device limit. You'll also need to import time.
suggestion
ctxTag, cancel := context.WithTimeout(ctx, 2*time.Second)
defer cancel()
if err := a.anonDeviceService.TagDevice(ctxTag, httpReqCopy, anonymous.AnonDeviceUI); err != nil {
Mirrors ai-code-review-evaluation#1 for like-for-like benchmarking.
enhance-anonymous-accessimplement-device-limitsOriginal PR excerpt: