# Internal error: undefined method \`visibility\_reason\_id'

**URL:** https://meta.discourse.org/t/internal-error-undefined-method-visibility-reason-id/308317
**Category:** Self-hosting
**Created:** [May 16, 2024, 8:55pm UTC](https://meta.discourse.org/t/internal-error-undefined-method-visibility-reason-id/308317 "2024-05-16T20:55:10Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jeanas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jeanas/32/281211_2.png) [@jeanas](https://meta.discourse.org/u/jeanas)
#### Post date: [May 16, 2024, 8:55pm UTC](https://meta.discourse.org/t/internal-error-undefined-method-visibility-reason-id/308317/1 "2024-05-16T20:55:10Z")

</div>

I manage a Discourse instance on [https://lilypond.community](https://lilypond.community). A few hours ago, I used the Web interface to upgrade Discourse to 3.3.0beta2. It failed with the same error as on [3.3.0.beta2-dev update error - #8 by david](https://meta.discourse.org/t/3-3-0-beta2-dev-update-error/308163/8). At that moment, I didn’t have the time to investigate, so I left it as-is, but the forum still looked functional. Now it’s giving

> Oops
> 
> The software powering this discussion forum encountered an unexpected problem. We apologize for the inconvenience.
> 
> Detailed information about the error was logged, and an automatic notification generated. We’ll take a look at it.
> 
> No further action is necessary. However, if the error condition persists, you can provide additional detail, including steps to reproduce the error, by posting a discussion topic in the site’s feedback category.

on any page (`/`, `/t/topic-slug`, etc).

I followed the advice on the linked topic:

```plaintext
cd /var/discourse
git pull
./launcher rebuild app
./launcher start app

```

but it didn’t help. I’m not 100% sure the problem is actually related to the upgrade, though I find it likely.

This is what I find in `/var/discourse/shared/standalone/log/rails/production.log`, just after trying to access the page `https://lilypond.community/t/effacer-les-citations-du-conducteur/5698/8`:

```plaintext
Started GET "/t/effacer-les-citations-du-conducteur/5698/8" for [IP redacted] at 2024-05-16 20:49:53 +0000
Processing by TopicsController#show as HTML
  Parameters: {"slug"=>"effacer-les-citations-du-conducteur", "topic_id"=>"5698", "post_number"=>"8"}
Completed 500 Internal Server Error in 39ms (ActiveRecord: 0.0ms | Allocations: 14832)
NoMethodError (undefined method `visibility_reason_id' for #<Topic id: 5698, title: "Effacer les citations du conducteur", [...]>)
app/serializers/topic_view_serializer.rb:327:in `include_visibility_reason_id?'
(eval):37:in `_fast_attributes'
app/controllers/topics_controller.rb:1360:in `block (2 levels) in perform_show_response'
app/controllers/topics_controller.rb:1354:in `perform_show_response'
app/controllers/topics_controller.rb:187:in `show'
app/controllers/application_controller.rb:423:in `block in with_resolved_locale'
app/controllers/application_controller.rb:423:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:64:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:391:in `call'
lib/middleware/csp_script_nonce_injector.rb:12:in `call'
config/initializers/008-rack-cors.rb:14:in `call'
config/initializers/100-quiet_logger.rb:20:in `call'
config/initializers/100-silence_logger.rb:29:in `call'
lib/middleware/enforce_hostname.rb:24:in `call'
lib/middleware/request_tracker.rb:277:in `call'
start
done

```

For a user page:

```plaintext
Started GET "/u/jeanas/" for [IP redacted] at 2024-05-16 20:47:21 +0000
Processing by UsersController#show as HTML
  Parameters: {"username"=>"jeanas"}
Completed 500 Internal Server Error in 180ms (ActiveRecord: 0.0ms | Allocations: 80166)
NoMethodError (undefined method `custom_homepage' for #<ThemeModifierHelper:0x00007f37a9f775c8 @theme_ids=[1]>)
app/serializers/user_serializer.rb:327:in `can_pick_theme_with_custom_homepage'
(eval):100:in `_fast_attributes'
app/controllers/users_controller.rb:152:in `block (2 levels) in show'
app/controllers/users_controller.rb:149:in `show'
app/controllers/application_controller.rb:423:in `block in with_resolved_locale'
app/controllers/application_controller.rb:423:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:64:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:393:in `call'
lib/middleware/csp_script_nonce_injector.rb:12:in `call'
config/initializers/008-rack-cors.rb:14:in `call'
config/initializers/100-quiet_logger.rb:20:in `call'
config/initializers/100-silence_logger.rb:29:in `call'
lib/middleware/enforce_hostname.rb:24:in `call'
lib/middleware/request_tracker.rb:277:in `call'

```

And for the root page:

```plaintext
Started GET "/" for [IP redacted] at 2024-05-16 20:54:16 +0000
NoMethodError (undefined method `custom_homepage' for #<ThemeModifierHelper:0x00007f37aba0c488 @theme_ids=[]>)
lib/homepage_helper.rb:5:in `resolve'
lib/homepage_constraint.rb:12:in `matches?'
lib/middleware/omniauth_bypass_middleware.rb:64:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:393:in `call'
lib/middleware/csp_script_nonce_injector.rb:12:in `call'
config/initializers/008-rack-cors.rb:14:in `call'
config/initializers/100-quiet_logger.rb:20:in `call'
config/initializers/100-silence_logger.rb:29:in `call'
lib/middleware/enforce_hostname.rb:24:in `call'
lib/middleware/request_tracker.rb:277:in `call'

```

---

<div class="post-metadata">

### Author: ![jeanas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jeanas/32/281211_2.png) [@jeanas](https://meta.discourse.org/u/jeanas)
#### Post date: [May 16, 2024, 9:13pm UTC](https://meta.discourse.org/t/internal-error-undefined-method-visibility-reason-id/308317/2 "2024-05-16T21:13:50Z")

</div>

Looking at the code, it seems that `visibility_reason_id` and such are database fields new in this version, that were supposed to be added to the existing database by migrations scripts (e.g., `db/migrate/20240423013808_add_visibility_reason_id_to_topics.rb`). I suspect that the upgrade stopped halfway before running these.

Is there a way to cleanly roll back to 3.3.0beta1 and redo the migration? If I do `git checkout v3.3.0.beta1` inside the Docker container (`./launcher enter app`), is it dangerous?

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [May 16, 2024, 9:29pm UTC](https://meta.discourse.org/t/internal-error-undefined-method-visibility-reason-id/308317/3 "2024-05-16T21:29:31Z")

</div>

Does it still happen if you rebuild a second time? What says the rebuild log if the issue persists? 🤔

---

<div class="post-metadata">

### Author: ![jeanas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jeanas/32/281211_2.png) [@jeanas](https://meta.discourse.org/u/jeanas)
#### Post date: [May 16, 2024, 9:45pm UTC](https://meta.discourse.org/t/internal-error-undefined-method-visibility-reason-id/308317/4 "2024-05-16T21:45:38Z")

</div>

Oh, that worked. Thank you!

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [June 15, 2024, 9:46pm UTC](https://meta.discourse.org/t/internal-error-undefined-method-visibility-reason-id/308317/5 "2024-06-15T21:46:15Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
