diff --git a/internal/api/attachments.go b/internal/api/attachments.go index 862f544..6bdb31b 100644 --- a/internal/api/attachments.go +++ b/internal/api/attachments.go @@ -186,9 +186,18 @@ func (a *apiServer) handleCreatePasteMultipart(w http.ResponseWriter, r *http.Re case "burn_after_read": p.BurnAfterRead = v == "true" || v == "1" || v == "on" case "burn_after_reads": - if n, err := strconv.Atoi(v); err == nil { - p.BurnAfterReads = &n + if v == "" { // absent value: unset, like the JSON path's omitempty + continue } + n, err := strconv.Atoi(v) + if err != nil { + // malformed burn_after_reads is a 400, not a silently-dropped + // budget: same 400-with-code shape the JSON path uses for + // invalid values (which fail unmarshal into the int field). + writeErrCode(w, 400, "burn_invalid", "burn_after_reads must be a positive number") + return + } + p.BurnAfterReads = &n } }