fix(podcasts): order selector validation — bind the htmx form wire format (issue #2)

WHY: htmx sends non-GET requests urlencoded by default; the SetFeedOrder
request struct only carried a json tag, so the binder left Order empty
and 'required' fired — the exact error the order dropdown AND the
Serial-suggestion button produced (hx-vals JSON also arrives
form-encoded). One form tag fixes both controls.

Regression test drives the exact wire format: urlencoded PUT with
order=oldest/native → 200, empty/invalid → 400.
This commit is contained in:
John O'Keefe committed 2026-10-29 19:45:46 -04:00
1 parent 8d9fb0046c
commit c753780817
2 files changed
+35 -1

No files matched your search

+1 -1
View File
@@ -459,7 +459,7 @@ func (h *PodcastHandler) SetFeedOrder(c *echo.Context) error {
return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid feed id"})
}
var req struct {
Order string `json:"order" validate:"required,oneof=native oldest newest"`
Order string `json:"order" form:"order" validate:"required,oneof=native oldest newest"`
}
if err := c.Bind(&req); err != nil {
return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid request"})