fix(feedback): repeated tags decode + inline error instead of bare 422 page #101
No reviewers
Labels
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
psa-systems/bunyip!101
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/feedback-form-tags-and-inline-error"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The feedback form rendered four checkboxes named
tags(Bug / Feature / Flow / Idea) backed byFeedbackForm.tags: Vec<String>, extracted via axum's stockFormextractor. The extractor usesserde_urlencoded, which has no special handling for repeated keys: as soon as the user ticked one box the request body becametags=Bug&...andserde_urlencodedfailed withinvalid type: string "Bug", expected a sequence. Worse, that failure surfaced as axum's bare 422 text - the user lost their typed message and there was no way to see what went wrong on the form page itself.Two-part fix in one PR:
Accept the raw body as
axum::body::Bytesand decode withform_urlencoded::parse. A newparse_feedback_form(body)helper walks the (key, value) pairs and buildsFeedbackInputdirectly, pushing eachtagsvalue into a Vec as it sees them. Empty / whitespace-only tag values are skipped. The natural HTML shape - one<input type="checkbox" name="tags">per option - now just works without any form-side rename or hidden-field workaround.Because the handler accepts
Bytes(which never rejects on shape), it always runs to render the feedback page. The "Please enter a message." branch already plumbed an inline error banner; reusing that surface means any future client-side hiccup also stays on-page instead of leaking the 422.Dependency:
form_urlencoded = "1"is promoted from a transitive (viaurl) to a direct dep on bunyip-web. The struct + serde derive + axum::Form / serde::Deserialize imports for the oldFeedbackFormare all removed.Reference: the saas frontend uses
tags[]on its FormData; bunyip's checkboxes still usetags(no brackets) because the manual decoder accepts both.