Skip to content

Surface admin form errors and publish an arrival window - #143

Merged
leowilkin merged 1 commit into
mainfrom
claude/admin-form-errors-arrival-window
Sep 20, 2026
Merged

leowilkin merged 1 commit into
mainfrom
claude/admin-form-errors-arrival-window

Conversation

@leowilkin

Copy link
Copy Markdown
Member

Why

Entering a support email outside @hackclub.com / @events.hackclub.com on the new-event form looked like nothing happened: no error, just a reset form. The 422 re-render was correct — but log_admin_action (an after_action on every non-GET admin request) then raised, because on a failed create the only record it can find is the unsaved event and AuditLog requires a record_id. The rescue re-raises in dev/test, so Rails replaced the form with its exception page, which carries <meta name="turbo-visit-control" content="reload">, and Turbo full-reloaded back to a blank form. This affected every admin create that fails validation, not just this field.

While in the area, events can now publish an arrival window, and a 500 on support change requests is fixed.

What changed

Admin form errors survive again

  • log_admin_action skips records that were never persisted (record.id.blank?).
  • Regression spec stubs find_changed_record: without that, the freshly-created signed-in user in request specs carries previous_changes and becomes the audit record, hiding the bug — which is why the existing 422 spec passed throughout.

Live support-email validation

  • New email-domain Stimulus controller: flags a disallowed domain as it is typed, on the create form and event settings. Domains come from Event::SUPPORT_EMAIL_DOMAINS, and setCustomValidity blocks the submit, so the server validation stays the source of truth.

Arrival window

  • New arrival_opens_at / arrival_closes_at on events, editable in the setup wizard's schedule step and in event settings, interpreted in the event's timezone like the other schedule fields.
  • The attendee dashboard's "When to arrive" now reads e.g. Arrive between 9:00 AM and 11:30 AM BST on Saturday, August 1. instead of the "an arrival window has not been published" fallback.
  • Also exposed through the series API (docs/openapi.yml updated, mint validate passes) and the MCP events toolbox.

Support change requests no longer 500

  • Parameters#fetch(:requested_changes, {}) wraps the Hash default in a fresh unpermitted Parameters, which raises UnfilteredParameters on #to_h. A support request sends no field changes, so every one of them hit it.

Testing

  • bundle exec rspec spec/models/event_spec.rb spec/requests/admin/event_setup_spec.rb spec/requests/registration_corrections_spec.rb spec/requests/registration_completion_states_spec.rb spec/toolboxes — 115 examples, 0 failures
  • node --test spec/javascript/email_domain_controller_test.mjs — 4 passing
  • bundle exec rubocop clean
  • Manually against a local server: an invalid support email now re-renders the form with "Support email must be a @hackclub.com or @events.hackclub.com address", and an arrival window saved through the wizard round-trips in the event's timezone.

Not yet given a visual pass in light/dark or on mobile.

A failed admin create re-rendered the form with a 422, but log_admin_action
then raised on the unsaved record (AuditLog needs a record_id) and re-raised
in development, so Rails swapped the form for an exception page carrying
turbo-visit-control: reload — the admin saw a silently reset form and no
error at all. Skip the audit log when the record was never persisted.

The support email field now also validates live against
Event::SUPPORT_EMAIL_DOMAINS, so an address outside Hack Club's domains is
flagged as it is typed instead of on submit.

Events gain an optional arrival window (arrival_opens_at / arrival_closes_at),
editable from the setup wizard and event settings and shown to attendees as
"when to arrive" on their dashboard in place of the "not published" fallback.

Also fixes a 500 on support change requests: Parameters#fetch wraps a Hash
default in a fresh unpermitted Parameters, which raised on #to_h whenever a
request carried no field changes.
@mintlify

mintlify Bot commented Sep 20, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
attend 🟢 Ready View Preview Sep 20, 2026, 1:30 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

@leowilkin
leowilkin enabled auto-merge (squash) September 20, 2026 13:31
@leowilkin
leowilkin merged commit 029db28 into main Sep 20, 2026
16 checks passed
@leowilkin
leowilkin deleted the claude/admin-form-errors-arrival-window branch September 20, 2026 14: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.

1 participant