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

AI-generated summary

A user, Firepup650, encountered an issue where failing to add a theme due to a file extension block prevented the theme from being added permanently. The error message indicated a duplicate key value in the database. sam suggested that the issue might be due to not cleaning up properly on error. Firepup650 provided reproduction steps and suspected that the theme’s components might be the cause.

However, Don discovered that the issue was actually due to a duplication in the theme’s about.json file. Firepup650 acknowledged the mistake and explained that the theme was heavily customized for personal use.

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.

Message

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.

Backtrace

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.

Edit:
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)

Hello :wave:

I checked your theme, it seems the problem is with your about.json.

In the components there is a duplication.

Line 29 with 38 :arrow_down_small:


However, you install quite a lot of components at the same time with the theme. Do they all necessary? :slightly_smiling_face:

2 Likes

Ah whoops! That’s on me, sorry.

I never really intended anyone else to use the theme, it’s just heavily tuned the way I like it, and it has the theme components I like having available.