readJSON wraps the request body in a MaxBytesReader and decodes into dst. Use this for every JSON-decoding handler to bound memory and reject obviously oversized payloads early. We deliberately do not DisallowUnknownFields — adding it would break existing clients that send forward-compatible extra f
(w http.ResponseWriter, r *http.Request, dst any, maxBytes int64)
| 58 | // send forward-compatible extra fields, and the SDKs publish typed |
| 59 | // requests so unknown-fields strictness adds little defense. |
| 60 | func readJSON(w http.ResponseWriter, r *http.Request, dst any, maxBytes int64) error { |
| 61 | r.Body = http.MaxBytesReader(w, r.Body, maxBytes) |
| 62 | return json.NewDecoder(r.Body).Decode(dst) |
| 63 | } |
| 64 | |
| 65 | // normalizeEmail is the agent-package-local alias for identity.NormalizeEmail. |
| 66 | // Defined here as a one-line forwarder so the existing call sites in this |