# Badge image missing issue

**URL:** <https://meta.discourse.org/t/badge-image-missing-issue/214455>\
**Category:** Product Support\
**Created:** [January 10, 2022, 10:00pm UTC](https://meta.discourse.org/t/badge-image-missing-issue/214455 "2022-01-10T22:00:09Z")\
**Posts on this page:** 10\
**Page:** 1

## AI-generated summary

The user [f1r4s](/t/-/214455/1) reports an issue with missing badge images after restoring a backup, receiving a `NoMethodError` related to `image_url`. The error occurs because the badge images are not properly linked or restored. [cocococosti](/t/-/214455/2) suggests verifying that the images were included in the backup and checking the `badges` and `uploads` tables to confirm the image IDs and file paths. They recommend using the Data Explorer plugin to inspect the badges table, though [f1r4s](/t/-/214455/7) notes they couldn't find the badge table. [Ihor_Shevchenko](/t/-/214455/8) asks if the issue was resolved, and [JammyDodger](/t/-/214455/9) references a related fix in another topic.

<div class="post-metadata">

**Author:** ![f1r4s](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/f1r4s/32/245347_2.png) [@f1r4s](https://meta.discourse.org/u/f1r4s)\
**Post date:** [January 10, 2022, 10:00pm UTC](https://meta.discourse.org/t/badge-image-missing-issue/214455/1 "2022-01-10T22:00:09Z")

</div>

Hello,

I have issue with badge section, i have modified some badges and add some images there; after 6 months i restore a backup and everything works fine execpt the badge section; i try to login with safe-mode and disable all plugins… but issue still same, how can i restore the badge sections withd default name and images ?

error show me

```plaintext
Message (2 copies reported)

NoMethodError (undefined method `url' for nil:NilClass)
app/models/badge.rb:306:in `image_url'
(eval):10:in `_fast_attributes'
app/controllers/application_controller.rb:484:in `serialize_data'
app/controllers/badges_controller.rb:30:in `index'
app/controllers/application_controller.rb:387:in `block in with_resolved_locale'
app/controllers/application_controller.rb:387:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:71:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:356:in `call'
config/initializers/100-quiet_logger.rb:23:in `call'
config/initializers/100-silence_logger.rb:31:in `call'
lib/middleware/enforce_hostname.rb:23:in `call'
lib/middleware/request_tracker.rb:198:in `call'

Backtrace

app/models/badge.rb:306:in `image_url'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:99:in `block in attribute'
(eval):10:in `_fast_attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:468:in `rescue in attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:455:in `attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:480:in `_serializable_hash'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:359:in `serializable_hash'
active_model_serializers (0.8.4) lib/active_model/array_serializer.rb:89:in `block in _serializable_array'
active_model_serializers (0.8.4) lib/active_model/array_serializer.rb:79:in `map'
active_model_serializers (0.8.4) lib/active_model/array_serializer.rb:79:in `_serializable_array'

Env

HTTP HOSTS: site.com

```

---

<div class="post-metadata">

**Author:** ![cocococosti](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cocococosti/32/231474_2.png) [@cocococosti](https://meta.discourse.org/u/cocococosti)\
**Post date:** [January 11, 2022, 7:19pm UTC](https://meta.discourse.org/t/badge-image-missing-issue/214455/2 "2022-01-11T19:19:21Z")

</div>

> [@f1r4s](#):
>
> i restore a backup and everything works fine execpt the badge section

Other images were restored correctly?

Did you make sure to include uploads in the backup?

 ![backup_options](https://global.discourse-cdn.com/meta/original/3X/3/4/34cd8f4db8e3eac9e7acd8686e2238327c4f1891.png)

Are you using s3 to store your uploads? If not, could you enter the container, and go to `/shared/uploads/default/original/1X` do you have files there?

---

<div class="post-metadata">

**Author:** ![f1r4s](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/f1r4s/32/245347_2.png) [@f1r4s](https://meta.discourse.org/u/f1r4s)\
**Post date:** [January 11, 2022, 7:24pm UTC](https://meta.discourse.org/t/badge-image-missing-issue/214455/3 "2022-01-11T19:24:20Z")

</div>

yes i don’t use s3, and i always use to include attachment pictures in backup…

what i’m looking for now how to make reset for badge images ??

---

<div class="post-metadata">

**Author:** ![cocococosti](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cocococosti/32/231474_2.png) [@cocococosti](https://meta.discourse.org/u/cocococosti)\
**Post date:** [January 11, 2022, 7:47pm UTC](https://meta.discourse.org/t/badge-image-missing-issue/214455/4 "2022-01-11T19:47:17Z")

</div>

Out of the box, there is no way to “make reset for badge images” that I know of.

What I’d do first is check that the badges missing images were at least restored. If you check the `badges` table you can get the ID of the image at the `image_upload` field. Then use that ID in the `uploads` table, to get the URL of the image, like so:

```plaintext
select url from uploads where id = <badge-upload-id>

```

The URL looks something like this: `/uploads/default/original/1X/c1325294cd04ae6e9072a2577543dad66cf31afe.jpeg` and from there, you can extract the name of the file, in this case it would be `c1325294cd04ae6e9072a2577543dad66cf31afe.jpeg`

Then you can check in the server that the image is there with `find` or whatever method you prefer

```plaintext
cd /
find . -name c1325294cd04ae6e9072a2577543dad66cf31afe.jpeg

```

Once you made sure the images were restored, at the right path, then you can continue debugging as the issue is somewhere else.

The version of Discourse from the backup is too different from the version of Discourse you are restoring into?

Maybe someone else in the community knows more about this, though.

---

<div class="post-metadata">

**Author:** ![f1r4s](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/f1r4s/32/245347_2.png) [@f1r4s](https://meta.discourse.org/u/f1r4s)\
**Post date:** [January 11, 2022, 7:52pm UTC](https://meta.discourse.org/t/badge-image-missing-issue/214455/5 "2022-01-11T19:52:21Z")

</div>

Perfect, but how can i know the missing badge url or name ?

I cannot find how i know the missing url or badge image name.

---

<div class="post-metadata">

**Author:** ![cocococosti](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cocococosti/32/231474_2.png) [@cocococosti](https://meta.discourse.org/u/cocococosti)\
**Post date:** [January 11, 2022, 7:57pm UTC](https://meta.discourse.org/t/badge-image-missing-issue/214455/6 "2022-01-11T19:57:19Z")

</div>

Follow the instruction here [Discourse Data Explorer](https://meta.discourse.org/t/data-explorer-plugin/32566) to install the [data explorer](https://meta.discourse.org/t/32566?silent=true) plugin, you can use it to inspect the badges table. Focus on your custom badges.

---

<div class="post-metadata">

**Author:** ![f1r4s](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/f1r4s/32/245347_2.png) [@f1r4s](https://meta.discourse.org/u/f1r4s)\
**Post date:** [January 11, 2022, 7:59pm UTC](https://meta.discourse.org/t/badge-image-missing-issue/214455/7 "2022-01-11T19:59:08Z")

</div>

I did install it; but i didn’t find the badge table;

this is the error i get when i open the profile of administrator;

```plaintext
Message

NoMethodError (undefined method `url' for nil:NilClass)
app/models/badge.rb:306:in `image_url'
(eval):10:in `_fast_attributes'
lib/freedom_patches/ams_include_without_root.rb:54:in `include!'
lib/freedom_patches/ams_include_without_root.rb:54:in `include!'
app/controllers/users_controller.rb:92:in `block (2 levels) in show'
app/controllers/users_controller.rb:89:in `show'
app/controllers/application_controller.rb:387:in `block in with_resolved_locale'
app/controllers/application_controller.rb:387:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:71:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:356:in `call'
config/initializers/100-quiet_logger.rb:23:in `call'
config/initializers/100-silence_logger.rb:31:in `call'
lib/middleware/enforce_hostname.rb:23:in `call'
lib/middleware/request_tracker.rb:198:in `call'

Backtrace

app/models/badge.rb:306:in `image_url'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:99:in `block in attribute'
(eval):10:in `_fast_attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:468:in `rescue in attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:455:in `attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:480:in `_serializable_hash'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:359:in `serializable_hash'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:448:in `block in merge_association'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:445:in `each'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:445:in `merge_association'

Env

HTTP HOSTS: site.com

```

---

<div class="post-metadata">

**Author:** ![Ihor\_Shevchenko](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ihor_shevchenko/32/252652_2.png) [@Ihor\_Shevchenko](https://meta.discourse.org/u/Ihor_Shevchenko)\
**Post date:** [August 13, 2022, 10:01am UTC](https://meta.discourse.org/t/badge-image-missing-issue/214455/8 "2022-08-13T10:01:21Z")

</div>

Hi @f1r4s  
I faced the same problem. Did you manage to solve this problem?

---

<div class="post-metadata">

**Author:** ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Post date:** [January 18, 2023, 11:34am UTC](https://meta.discourse.org/t/badge-image-missing-issue/214455/9 "2023-01-18T11:34:53Z")

</div>

I believe this was resolved in this topic:

> [@Profile preference 404 error/ admin profile not work](https://meta.discourse.org/t/profile-preference-404-error-admin-profile-not-work/216640):
>
> I have this issue since a month; but i try several time upgrade; migrate the database to new one; etc… with no fix. It was in admin user; i try to migrate the admin data to new one; same issue.. i cannot open the preference or profile and i get 404; i see same issue but none explain how to fix and it’s quit old since 3 years. same issue and they mention it’s fixed but too old and none explaine how to fix.

---

<div class="post-metadata">

**Author:** ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Post date:** [January 18, 2023, 11:35am UTC](https://meta.discourse.org/t/badge-image-missing-issue/214455/10 "2023-01-18T11:35:00Z")

</div>

Closed on January 18, 2023, 11:35am UTC


