Skip to content

Fix support ticket create 500 on invalid priority - #177

Closed
thibaudgg wants to merge 2 commits into
masterfrom
cursor/fix-support-ticket-priority-e149
Closed

thibaudgg wants to merge 2 commits into
masterfrom
cursor/fix-support-ticket-priority-e149

Conversation

@thibaudgg

@thibaudgg thibaudgg commented Sep 13, 2026

Copy link
Copy Markdown
Member

Problem

Production AppSignal incident #733: ArgumentError: '2' is not a valid priority on SupportTicketsController#create (tenant ragedevert).

The new support ticket form used ticket_priority_marks_collection, which posted Rails enum integers (0/1/2). HTML always submits those as strings. Rails enums accept the integer 2 (high) or the name "high", but reject "2" as an unknown key and raise during assign_attributes — a 500 instead of a form error.

Selecting ‼️ (high) on the live form is what triggered this.

Fix

  • Submit enum names (normal / medium / high) from the create/edit priority select.
  • Keep integer values on the index filter, where Ransack queries the integer column.
  • enum :priority, …, validate: true so unexpected values (including "2") become an inclusion error and re-render the form, instead of raising.
  • Set required: false on the select so Rails does not reject include_blank: false now that the enum is validated. The model still rejects bad priorities; the picker keeps its default of normal.

Tests

  • Model: "2" does not raise; it fails inclusion validation. "high" remains valid.
  • Controller: form options are names; posting "high" creates the ticket; posting "2" returns 422 with a priority field error.

Do not merge or deploy from this PR.

Open in Web Open in Cursor 

cursoragent and others added 2 commits September 13, 2026 12:32
The priority select posted integer enum values as strings ("2"), which
Rails rejects as invalid keys. Submit enum names from the form, keep
integer values for the Ransack filter, and validate the enum so bad
priorities become form errors instead of a 500.

Co-authored-by: Thibaud Guillaume-Gentil <thibaud@thibaud.gg>
enum validate: true marks priority as required, and Rails then rejects
include_blank: false on the select. The model still validates inclusion;
the input stays a compact mark picker with a default of normal.

Co-authored-by: Thibaud Guillaume-Gentil <thibaud@thibaud.gg>
@thibaudgg

Copy link
Copy Markdown
Member Author

Replaced by 5256a5e

@thibaudgg thibaudgg closed this Sep 13, 2026
@thibaudgg
thibaudgg deleted the cursor/fix-support-ticket-priority-e149 branch September 15, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants