Skip to content

Don't 500 Activity Participations when icalendar token decryption fails - #179

Closed
thibaudgg wants to merge 2 commits into
masterfrom
cursor/icalendar-token-decrypt-3b56
Closed

thibaudgg wants to merge 2 commits into
masterfrom
cursor/icalendar-token-decrypt-3b56

Conversation

@thibaudgg

@thibaudgg thibaudgg commented Sep 14, 2026

Copy link
Copy Markdown
Member

Problem

AppSignal incident #440 (ActionView::Template::Error wrapping ActiveRecord::Encryption::Errors::Decryption) takes down ActivityParticipationsController#index (GET /activity_participations).

The calendar sidebar is gated with Current.org.icalendar_auth_token?. That predicate decrypts Organization#icalendar_auth_token. For tenants whose ciphertext is corrupt or encrypted under the wrong key (latest sample: demo-en), ActiveAdmin sidebar rendering raises and the whole index returns 500.

Fix

Rescue ActiveRecord::Encryption::Errors::Decryption in Organization#icalendar_auth_token and treat it as a missing token (nil / icalendar_auth_token? false).

  • The Activity Participations index renders without the calendar subscribe sidebar.
  • The public calendar feed returns 401 instead of 500.
  • No silent token rewrite on GET (existing subscriptions were already unusable).

Chose a reader-level rescue over a sidebar-only guard so every presence check and token consumer fails closed the same way.

Tests

  • Organization: undecryptable ciphertext → nil / not present
  • Admin index: 200 and no calendar sidebar when decryption fails; happy path still shows the subscribe panel
  • Calendar feed: 401 when the stored token cannot be decrypted

Tests write a corrupted encrypted payload with raw SQL so Active Record does not re-encrypt it.

Does not close or comment on the AppSignal incident.

Open in Web Open in Cursor 

cursoragent and others added 2 commits September 14, 2026 12:42
ActivityParticipations#index 500s when Organization#icalendar_auth_token
cannot be decrypted, because the calendar sidebar presence check reads
the encrypted attribute. Treat decryption failures as a missing token so
that page still renders.

Co-authored-by: Thibaud Guillaume-Gentil <thibaud@thibaud.gg>
Write a corrupted encrypted payload via SQL so Active Record does not
re-encrypt it. That reproduces the production Decryption error on read.

Co-authored-by: Thibaud Guillaume-Gentil <thibaud@thibaud.gg>
@thibaudgg
thibaudgg marked this pull request as ready for review September 14, 2026 12:50
@thibaudgg

Copy link
Copy Markdown
Member Author

I fixed the encrypted keys directly.

@thibaudgg thibaudgg closed this Sep 14, 2026
@thibaudgg
thibaudgg deleted the cursor/icalendar-token-decrypt-3b56 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