Failing to add a theme permanently prevents that theme from being added

Just had this happen on a new forum, I tried to add a theme, which failed due to one of the file extensions. I then allowed * temporarily just to try to fix the issue, and then I started getting 500s trying to add the theme.


Failed to process hijacked response correctly : ActiveRecord::RecordNotUnique : PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_child_themes_on_parent_theme_id_and_child_theme_id"
DETAIL:  Key (parent_theme_id, child_theme_id)=(50, 35) already exists.


rack-mini-profiler-3.3.0/lib/patches/db/pg.rb:69:in `exec_params'
rack-mini-profiler-3.3.0/lib/patches/db/pg.rb:69:in `exec_params'
activerecord-7.0.8/lib/active_record/connection_adapters/postgresql_adapter.rb:768:in `block (2 levels) in exec_no_cache'
activesupport-7.0.8/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
activesupport-7.0.8/lib/active_support/dependencies/interlock.rb:41:in `permit_concurrent_loads'
activerecord-7.0.8/lib/active_record/connection_adapters/postgresql_adapter.rb:767:in `block in exec_no_cache'
activesupport-7.0.8/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
activesupport-7.0.8/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
activesupport-7.0.8/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
activesupport-7.0.8/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'

oh odd, I guess we are not cleaning up properly on error.

Is this reproducible?

I’ll double check, but reproduction steps should be:

  1. Find a theme with some file that’s not allowed by default (or delete everything from the theme allowed extensions list or similar)
  2. Try to import the theme
  3. See it fail because of the extension
  4. Allow relevant extensions (or just *)
  5. Still try and fail to import the theme.

The theme might also need some theme components attached to it, I’m not sure.

I originally caused this using my own theme, but AFAIK most themes should be theoretically able to cause this.

Right, the only real mandatory condition here seems to be the blocked file, so a theme with a custom font, logo, etc can trigger it if you disallow that file extension. (Also, staff uploads apparently override theme uploads, so make sure it’s not allowed in either setting)